@arcgis/core 4.27.0-rc.0 → 4.27.0-rc.2

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 (207) hide show
  1. package/README.md +2 -2
  2. package/arcade/featureSetUtils.js +1 -1
  3. package/arcade/featureset/actions/GroupBy.js +1 -1
  4. package/arcade/featureset/actions/OrderBy.js +1 -1
  5. package/arcade/functions/featuresetbase.js +1 -1
  6. package/arcade/functions/featuresetstring.js +1 -1
  7. package/arcade/languageUtils.js +1 -1
  8. package/arcade/treeAnalysis.js +1 -1
  9. package/assets/esri/core/workers/RemoteClient.js +1 -1
  10. package/assets/esri/core/workers/chunks/0407bf97ad621c89a734.js +1 -0
  11. package/assets/esri/core/workers/chunks/0610691a0c0d9fbbd6d2.js +1 -0
  12. package/assets/esri/core/workers/chunks/0a86c458916e83d6c523.js +1 -0
  13. package/assets/esri/core/workers/chunks/14145959a3dab1437818.js +1 -0
  14. package/assets/esri/core/workers/chunks/16db0bc87d87a7313dc4.js +1 -0
  15. package/assets/esri/core/workers/chunks/183e2e0cb86c1c640d94.js +1 -0
  16. package/assets/esri/core/workers/chunks/19d329b9d4ec2eff1d13.js +1 -0
  17. package/assets/esri/core/workers/chunks/1b8074269800b384ecf6.js +1 -0
  18. package/assets/esri/core/workers/chunks/1f69fb9687de9ebfcf90.js +1 -0
  19. package/assets/esri/core/workers/chunks/2154d395f405be3cd3ba.js +1 -0
  20. package/assets/esri/core/workers/chunks/{33dbba3b7fc648437e50.js → 21e1f3b11e7d363b727a.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{31a158c73994603c169d.js → 2446e336b1f7256d4fde.js} +1 -1
  22. package/assets/esri/core/workers/chunks/29290a44fd3b183c24e3.js +1 -0
  23. package/assets/esri/core/workers/chunks/2b55295590b4a0503749.js +1 -0
  24. package/assets/esri/core/workers/chunks/{f498c4d4831141125781.js → 2f5639886f577baedbca.js} +1 -1
  25. package/assets/esri/core/workers/chunks/33901eb1574e46abd9af.js +1 -0
  26. package/assets/esri/core/workers/chunks/{9c78ad5ab57e0d47ac43.js → 3ba2fcb9110230f8790c.js} +1 -1
  27. package/assets/esri/core/workers/chunks/3e239bfad611985e50fb.js +1 -0
  28. package/assets/esri/core/workers/chunks/42f3421740a5479559dc.js +1 -0
  29. package/assets/esri/core/workers/chunks/471f6eba213412b82840.js +1 -0
  30. package/assets/esri/core/workers/chunks/53ad34bf32f5f3d4fe18.js +1 -0
  31. package/assets/esri/core/workers/chunks/{97cdbec7532cfcdf9ad2.js → 595a2baa04d92de59558.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{2e627c94e57c924e5917.js → 5e6471dd2a08e66b47d0.js} +79 -81
  33. package/assets/esri/core/workers/chunks/624521961fe1f2c4f2c5.js +1 -0
  34. package/assets/esri/core/workers/chunks/{212d59764c275c763941.js → 659b7bad7281c0e2aed3.js} +1 -1
  35. package/assets/esri/core/workers/chunks/6a3d611e8842afbb50ab.js.LICENSE.txt +1 -1
  36. package/assets/esri/core/workers/chunks/6cd248d065f6d1616294.js +1 -0
  37. package/assets/esri/core/workers/chunks/6e562fa57c0347091154.js +1 -0
  38. package/assets/esri/core/workers/chunks/6f510f28526c73ab453c.js +1 -0
  39. package/assets/esri/core/workers/chunks/7479dc0c790337af7597.js +1 -0
  40. package/assets/esri/core/workers/chunks/{e88cff2537be52da6531.js → 74fd2059ddda9083cbcc.js} +1 -1
  41. package/assets/esri/core/workers/chunks/7dc6774c77c822b68c99.js +1 -0
  42. package/assets/esri/core/workers/chunks/82a103a8b5382300889d.js +1 -0
  43. package/assets/esri/core/workers/chunks/83e3d104886b48f00397.js +1 -0
  44. package/assets/esri/core/workers/chunks/{9849f64793f2ad39366b.js → 9290b0d330f02233d803.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{3c5a64a545272f148e93.js → 9621b7d8d951aa881686.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{36df72362b38759b895b.js → 9648a8f2b24f1ca3d637.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{ad18fb7bb54a0c4bdb38.js → a20361b4d3bdd7d196ca.js} +1 -1
  48. package/assets/esri/core/workers/chunks/a7fd2a95fde197c06828.js +1 -0
  49. package/assets/esri/core/workers/chunks/b0cda39b53ecd6c44cd0.js +1 -0
  50. package/assets/esri/core/workers/chunks/b2a423d9ce8bb784267c.js +1 -0
  51. package/assets/esri/core/workers/chunks/{b6e173eddaad4244cb5f.js → b31974524932e638df8c.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{df0453cdfe685d6436cc.js → b6dc41fce601b9d3480e.js} +1 -1
  53. package/assets/esri/core/workers/chunks/b8e6c64792a512df4c4d.js +1 -0
  54. package/assets/esri/core/workers/chunks/c6617a937440701c0180.js +1 -0
  55. package/assets/esri/core/workers/chunks/d8607326a199dd994844.js +1 -0
  56. package/assets/esri/core/workers/chunks/da57eba2fe25495ea217.js +1 -0
  57. package/assets/esri/core/workers/chunks/dabd889e064c4e7807fa.js +1 -0
  58. package/assets/esri/core/workers/chunks/{39e473586579d11d6732.js → e2432871f1329f47465d.js} +1 -1
  59. package/assets/esri/core/workers/chunks/ee5ee03dd2c7dc940272.js +1 -0
  60. package/assets/esri/core/workers/chunks/{c83669cf08391a62fb72.js → f1da7b29eecad0e9efae.js} +1 -1
  61. package/assets/esri/core/workers/chunks/f35895e03c036d67b3ed.js +1 -0
  62. package/assets/esri/core/workers/chunks/f505ebd4bd3bfb6c790d.js +1 -0
  63. package/assets/esri/core/workers/chunks/f6e68befe2812b90b40d.js +1 -0
  64. package/assets/esri/core/workers/chunks/{3c6c082157c916f8ddba.js → ffe61d5a6a9b34bee9d4.js} +1 -1
  65. package/assets/esri/themes/base/widgets/_Bookmarks.scss +5 -0
  66. package/assets/esri/themes/base/widgets/_Feature.scss +4 -0
  67. package/assets/esri/themes/base/widgets/_FeatureContent.scss +9 -2
  68. package/assets/esri/themes/base/widgets/_Features.scss +5 -7
  69. package/assets/esri/themes/base/widgets/_Popup.scss +3 -3
  70. package/assets/esri/themes/base/widgets/_ScaleRangeSlider.scss +1 -0
  71. package/assets/esri/themes/base/widgets/_Swipe.scss +11 -0
  72. package/assets/esri/themes/dark/main.css +1 -1
  73. package/assets/esri/themes/light/main.css +1 -1
  74. package/assets/esri/themes/light/view.css +1 -1
  75. package/chunks/DefaultMaterial.glsl.js +3 -2
  76. package/chunks/SSAO.glsl.js +1 -1
  77. package/chunks/ShadowCastAccumulate.glsl.js +1 -1
  78. package/chunks/languageUtils.js +1 -1
  79. package/core/timeUtils.js +1 -1
  80. package/geometry/Mesh.js +1 -1
  81. package/geometry/support/DoubleArray.js +1 -1
  82. package/geometry/support/meshUtils/bounds.js +5 -0
  83. package/geometry/support/meshUtils/georeference.js +1 -1
  84. package/geometry/support/meshVertexSpaceUtils.js +5 -0
  85. package/interfaces.d.ts +181 -33
  86. package/kernel.js +1 -1
  87. package/layers/FeatureLayer.js +1 -1
  88. package/layers/StreamLayer.js +1 -1
  89. package/layers/VideoLayer.js +1 -1
  90. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  91. package/layers/graphics/controllers/StreamController.js +1 -1
  92. package/layers/graphics/data/QueryEngine.js +1 -1
  93. package/layers/graphics/data/attributeSupport.js +1 -1
  94. package/layers/graphics/editingSupport.js +1 -1
  95. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  96. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  97. package/layers/support/FeatureReductionBinning.js +1 -1
  98. package/layers/support/FeatureReductionCluster.js +1 -1
  99. package/layers/support/featureLayerUtils.js +1 -1
  100. package/layers/support/rasterFunctions/colormaps.js +1 -1
  101. package/layers/video/VideoController.js +1 -1
  102. package/layers/video/videoUtils.js +5 -0
  103. package/package.json +2 -2
  104. package/renderers/support/utils.js +1 -1
  105. package/rest/support/meshFeatureSet.js +1 -1
  106. package/smartMapping/symbology/flow.js +1 -1
  107. package/statistics/utils.js +1 -1
  108. package/support/arcadeUtils.js +1 -1
  109. package/support/revision.js +1 -1
  110. package/symbols/cim/CIMSymbolHelper.js +1 -1
  111. package/symbols/cim/effects/EffectBuffer.js +1 -1
  112. package/symbols/cim/effects/EffectDonut.js +1 -1
  113. package/symbols/cim/effects/EffectOffset.js +1 -1
  114. package/views/2d/layers/StreamLayerView2D.js +1 -1
  115. package/views/2d/layers/features/Store2D.js +1 -1
  116. package/views/2d/layers/features/sources/StreamSource.js +1 -1
  117. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  118. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  119. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  120. package/views/3d/layers/I3SMeshView3D.js +1 -1
  121. package/views/3d/layers/II3SMeshView3D.js +1 -1
  122. package/views/3d/layers/SceneLayerView3D.js +1 -1
  123. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  124. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  125. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  126. package/views/3d/layers/graphics/webStyleUtils.js +1 -1
  127. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  128. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  129. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  130. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  131. package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
  132. package/views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js +3 -9
  133. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +12 -9
  134. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js +10 -10
  135. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
  136. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterDistortion.glsl.js +2 -2
  137. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +8 -8
  138. package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
  139. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  140. package/views/3d/webgl-engine/lib/ShadowHighlight.js +1 -1
  141. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  142. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  143. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  144. package/views/3d/webgl-engine/materials/pbrUtils.js +5 -0
  145. package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +1 -1
  146. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  147. package/views/3d/webgl-engine/shaders/ShadowHighlightTechnique.js +1 -1
  148. package/views/draw/DrawGraphicTool.js +1 -1
  149. package/views/layers/GroupLayerView.js +1 -1
  150. package/webdoc/support/writeUtils.js +1 -1
  151. package/widgets/Bookmarks/css.js +1 -1
  152. package/widgets/Bookmarks.js +1 -1
  153. package/widgets/Daylight/DaylightViewModel.js +1 -1
  154. package/widgets/Editor/EditorViewModel.js +1 -1
  155. package/widgets/Editor/UpdateWorkflow.js +1 -1
  156. package/widgets/Editor/Workflow.js +1 -1
  157. package/widgets/Editor/workflowUtils.js +1 -1
  158. package/widgets/Editor.js +1 -1
  159. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  160. package/widgets/Feature/FeatureRelationship.js +1 -1
  161. package/widgets/FeatureForm/EditableInput.d.ts +2 -2
  162. package/widgets/FeatureTable/FieldColumn.js +1 -1
  163. package/widgets/Features.js +1 -1
  164. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  165. package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
  166. package/widgets/UtilityNetworkTrace/support/ResultAreaHandler.js +1 -1
  167. package/widgets/UtilityNetworkTrace.js +1 -1
  168. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  169. package/widgets/UtilityNetworkValidateTopology.js +1 -1
  170. package/widgets/ValuePicker/ValuePickerBaseComponent.js +1 -1
  171. package/widgets/ValuePicker.js +1 -1
  172. package/assets/esri/core/workers/chunks/0b03165dbf289797cefa.js +0 -1
  173. package/assets/esri/core/workers/chunks/0c1c0024879f944f44c4.js +0 -1
  174. package/assets/esri/core/workers/chunks/13a48796905613bc1679.js +0 -1
  175. package/assets/esri/core/workers/chunks/1ea1104651ab15f9a13c.js +0 -1
  176. package/assets/esri/core/workers/chunks/2108cfc7921430f0b805.js +0 -1
  177. package/assets/esri/core/workers/chunks/2eacca322737aafd8f0c.js +0 -1
  178. package/assets/esri/core/workers/chunks/39577683e334eb4d904c.js +0 -1
  179. package/assets/esri/core/workers/chunks/39714837f9d3708e3806.js +0 -1
  180. package/assets/esri/core/workers/chunks/3fe357df92afa1bee70a.js +0 -1
  181. package/assets/esri/core/workers/chunks/4d3deeb0ebd0ce8c1215.js +0 -1
  182. package/assets/esri/core/workers/chunks/576bddc3fa7d91a7e5bd.js +0 -1
  183. package/assets/esri/core/workers/chunks/623d6710a4f800c622ce.js +0 -1
  184. package/assets/esri/core/workers/chunks/6782cc3feb713676d544.js +0 -1
  185. package/assets/esri/core/workers/chunks/6e7178de0b2c3d2f7e6b.js +0 -1
  186. package/assets/esri/core/workers/chunks/785a6c925f29bc962992.js +0 -1
  187. package/assets/esri/core/workers/chunks/78ce0b1af62435d8ebf4.js +0 -1
  188. package/assets/esri/core/workers/chunks/79d2baf392589588ef9b.js +0 -1
  189. package/assets/esri/core/workers/chunks/7bbdba52157da13a01fc.js +0 -1
  190. package/assets/esri/core/workers/chunks/7ec6be2bc0f354011e46.js +0 -1
  191. package/assets/esri/core/workers/chunks/84860b535a70ec448cfe.js +0 -1
  192. package/assets/esri/core/workers/chunks/9035d9e09a4e7cb94d37.js +0 -1
  193. package/assets/esri/core/workers/chunks/956b0fef7bc849415354.js +0 -1
  194. package/assets/esri/core/workers/chunks/9ab98321a4a7eaeeb018.js +0 -1
  195. package/assets/esri/core/workers/chunks/9cb7a68ff46e5c43e1d2.js +0 -1
  196. package/assets/esri/core/workers/chunks/a0f7f7f578521970c714.js +0 -1
  197. package/assets/esri/core/workers/chunks/a60eac45d3c65bd0216f.js +0 -1
  198. package/assets/esri/core/workers/chunks/aca5260f6984952a6e3d.js +0 -1
  199. package/assets/esri/core/workers/chunks/b05be356743fa5d24573.js +0 -1
  200. package/assets/esri/core/workers/chunks/ba6024465308c248170b.js +0 -1
  201. package/assets/esri/core/workers/chunks/d0983f808008920514f2.js +0 -1
  202. package/assets/esri/core/workers/chunks/dab832799bc06b0fec34.js +0 -1
  203. package/assets/esri/core/workers/chunks/e45d36aef2bc69ee9132.js +0 -1
  204. package/assets/esri/core/workers/chunks/e5bbd4cc5edbf7ab3624.js +0 -1
  205. package/assets/esri/core/workers/chunks/e700cf4d1f99291a4396.js +0 -1
  206. package/assets/esri/core/workers/chunks/f398a5cf33c3fd2522a5.js +0 -1
  207. package/assets/esri/core/workers/chunks/f4ee94a6cde4ea8837f1.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../chunks/tslib.es6.js";import{isSome as e}from"../core/arrayUtils.js";import{eventKey as o}from"../core/events.js";import{watch as s,initial as i,on as r}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import{cast as n}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{formatDate as l,convertDateFormatToIntlOptions as u}from"../intl/date.js";import{SlideThumbnail as m}from"../webdoc/support/SlideThumbnail.js";import k from"./Widget.js";import h from"./Bookmarks/BookmarksUserState.js";import c from"./Bookmarks/BookmarksViewModel.js";import{CSS as p}from"./Bookmarks/css.js";import b from"./FeatureTable/Grid/support/ButtonMenu.js";import _ from"./FeatureTable/Grid/support/ButtonMenuItem.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{Heading as B}from"./support/Heading.js";import{isActivationKey as f}from"./support/widgetUtils.js";import{messageBundle as v}from"./support/decorators/messageBundle.js";import{vmEvent as E}from"./support/decorators/vmEvent.js";import{tsx as I}from"./support/jsxFactory.js";import y from"sortablejs";function S(t,e,o){t.splice(o,0,t.splice(e,1)[0])}const w="bookmarks",T="data-bookmark-uid",A={addBookmark:!0,thumbnail:!0,time:!0},x=/^https:\/\/.*/i,U="esri.widgets.Bookmarks";let C=class extends k{constructor(t,e){super(t,e),this._tooltipReferenceMap=new Map,this._addInputNode=null,this._editInputNode=null,this._urlEditInputNode=null,this._addBookmarkButtonNode=null,this._focusAddBookmarkButton=!1,this._focusEditInputBox=!1,this._focusAddInputBox=!1,this._focusUrlEditInputBox=!1,this._sortable=null,this._sortableNode=null,this._focusSortUid=null,this._selectedSortUid=null,this._sortableSavedItems=[],this._editIncludeTimeExtent=void 0,this._userState=null,this.disabled=!1,this.editingEnabled=!1,this.headingLevel=2,this.iconClass=p.widgetIcon,this.icon=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.viewModel=new c,this.visibleElements={...A}}initialize(){this.addHandles([s((()=>this.viewModel?.bookmarks),(()=>this._bookmarksInitialized()),i),s((()=>this.editingEnabled),(()=>this._toggleSorting()),i)])}destroy(){this.removeAllHandles(),this._destroySortable(),this._editMenu.destroy(),this._tooltipReferenceMap.clear()}loadDependencies(){return g({label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}get _editMenuItems(){const{messages:t,_userState:o}=this,s=o?.editedBookmark?.thumbnail?.url;return[new _({label:t?.menu.refreshThumbnail,iconClass:p.iconRefresh,clickFunction:()=>this._refreshThumbnail()}),new _({label:s&&x.test(s)?t?.menu.editImageUrl:t?.menu.useImageUrl,iconClass:p.iconLink,clickFunction:()=>this._startUseImageUrl()}),s?new _({label:t?.menu.removeThumbnail,iconClass:p.iconRemove,clickFunction:()=>this._removeThumbnail()}):null].filter(e)}get _editMenu(){const{_editMenuItems:t,messages:e,disabled:o}=this,s=this._get("_editMenu");s&&s.destroy();const i=new b({disabled:o,iconClass:p.iconHandleHorizontal,label:e?.menu.label});return i.items=t,i}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(t){this.viewModel.defaultCreateOptions=t}get defaultEditOptions(){return this.viewModel.defaultEditOptions}set defaultEditOptions(t){this.viewModel.defaultEditOptions=t}get bookmarks(){return this.viewModel.bookmarks}set bookmarks(t){this.viewModel.bookmarks=t}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(t){this.viewModel.goToOverride=t}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}castVisibleElements(t){return{...A,...t}}endAddBookmark(){this._userState=null}goTo(t){return this.viewModel.goTo(t)}render(){const{state:t}=this.viewModel,e="loading"===t?this.renderLoading():this.renderBookmarks();return I("div",{class:this.classes(p.base,p.esriWidget,{[p.esriWidgetDisabled]:this.disabled})},e)}startAddBookmark(){this._userState=new h({state:"add"}),this._focusAddInputBox=!0,this.scheduleRender()}renderBookmarkTooltips(t){return t.toArray().map((t=>this.renderBookmarkTooltip(t)))??[]}renderBookmarkTooltip(t){const{_tooltipReferenceMap:e,messagesCommon:o}=this,s=this._getBookmarkTitle(t),i=`${o?.dragHandleTitle} ${s}`;return t?I("calcite-tooltip",{key:`tooltip-${t.uid}`,label:i,referenceElement:e.get(t.uid)},i):null}renderLoading(){return I("div",{class:p.loaderContainer,key:"loader",tabIndex:this.disabled?-1:void 0},I("div",{class:p.loader}))}renderNoBookmarksContainer(){const{messages:t,disabled:e}=this;return I("div",{class:p.noBookmarksContainer,key:"no-bookmarks",tabIndex:e?-1:void 0},I("span",{"aria-hidden":"true",class:this.classes(p.noBookmarksIcon,p.widgetIcon)}),I(B,{level:this.headingLevel,class:this.classes(p.header,p.noBookmarksHeader)},t?.noBookmarksHeading),I("p",{class:p.noBookmarksDescription},t?.noBookmarksDescription))}renderAddBookmarkLoading(){return I("div",{key:"adding-bookmark",class:p.addingBookmark},I("span",{"aria-hidden":"true",class:this.classes(p.loading,p.rotating)}),this.messages?.addingBookmark)}renderBookmarkItems(t){if(!t)return[];const{_userState:e,editingEnabled:o}=this;return t.map((t=>o&&t&&e&&("edit"===e.state||"edit-thumbnail"===e.state)&&e.bookmark===t?"edit-thumbnail"===e.state?this.renderEditingBookmarkUrl(e.editedBookmark):this.renderEditingBookmark(e.editedBookmark):this.renderBookmark(t))).toArray()}renderBookmarksContainer(t){const{_userState:e,editingEnabled:o,disabled:s}=this,i="add"===e?.state,r=o&&!i?this.renderAddBookmarkButton():null,a=o?i&&e.loading?this.renderAddBookmarkLoading():"add"===e?.state?this.renderAddingBookmark():null:null;return[I("ul",{key:"bookmark-list","aria-label":this.messages?.widgetLabel,class:this.classes(p.bookmarkList,{[p.bookmarkListSortable]:this.editingEnabled}),afterCreate:this._sortNodeCreated,afterRemoved:this._destroySortable,"data-node-ref":"_sortableNode",bind:this,tabIndex:s?-1:void 0},this.renderBookmarkItems(t)),r,a]}renderAddBookmarkButton(){return this.visibleElements.addBookmark?I("div",{key:"add-bookmark-item",class:p.addBookmark},I("button",{class:this.classes(p.esriButton,p.esriButtonTertiary,p.addBookmarkButton),disabled:this.disabled,onclick:this.startAddBookmark,afterCreate:this._storeAddBookmarkButton,afterUpdate:this._storeAddBookmarkButton,"data-node-ref":"_addBookmarkButtonNode",bind:this,type:"button"},I("span",{"aria-hidden":"true",class:this.classes(p.addBookmarkIcon,p.iconPlus)}),this.messages?.addBookmark)):null}renderBookmarks(){const{bookmarks:t}=this.viewModel,e=t&&t.filter(Boolean),o=e&&e.length,s=o||this.editingEnabled?this.renderBookmarksContainer(e):null;return[o?null:this.renderNoBookmarksContainer(),s,this.renderBookmarkTooltips(t)]}renderEditContainer(t){const{messagesCommon:e,disabled:o}=this,s=this._getBookmarkTitle(t);return I("div",{class:p.bookmarkEditButtonContainer,key:"edit-container"},I("button",{disabled:o,title:`${e?.edit} ${s}`,"aria-label":`${e?.edit} ${s}`,"data-bookmark":t,onclick:this._showEditBookmarkForm,bind:this,class:p.bookmarkEditButton,type:"button"},I("span",{"aria-hidden":"true",class:p.iconEdit})))}renderDragHandle(t){const{messagesCommon:e,disabled:o}=this,s=this._getBookmarkTitle(t),i={[T]:t.uid};return I("div",{role:"button",tabIndex:o?-1:0,key:"drag-handle",bind:this,class:p.bookmarkDragHandle,onkeydown:this._dragHandleKeydown,"data-bookmark":t,afterCreate:this._focusDragHandle,afterUpdate:this._focusDragHandle,onblur:this._dragHandleBlur,"aria-pressed":this._selectedSortUid===t.uid?"true":"false","aria-label":`${e?.dragHandleTitle} ${s}`,...i},I("span",{"aria-hidden":"true",class:this.classes(p.bookmarkDragHandleIcon,p.iconHandle)}))}renderBookmarkImageIcon(){return I("span",{"aria-hidden":"true",class:this.classes(p.bookmarkIcon,p.widgetIcon)})}renderBookmarkImage(t){const{visibleElements:e}=this,{thumbnail:o}=t,s=o&&o.url||"";return e.thumbnail&&s?I("img",{src:s,alt:"",class:p.bookmarkImage}):null}renderBookmarkTimeSwitch(t){const{messages:e,disabled:o}=this,{timeExtent:s}=t,{view:i}=this.viewModel;return i?.timeExtent??s?I("calcite-label",{layout:"inline-space-between"},e?.includeTimeExtent,I("calcite-switch",{scale:"s",disabled:o,checked:!!s,onCalciteSwitchChange:t=>{const e=t.currentTarget;this._editIncludeTimeExtent=!!e.checked}})):null}renderBookmarkTimeExtent(t){const{visibleElements:e}=this,{timeExtent:o}=t;return o?I("span",{class:p.timeExtent},[null!=o.start&&I("span",{key:"start-date-group",class:p.timeExtentGroup},I("span",{key:"start-date",class:p.timeExtentDate},this._formatDate(o.start)),e.time&&I("span",{key:"start-time",class:p.timeExtentTime},this._formatTime(o.start))),null!=o.end&&(null==o.start||o.start.getTime()!==o.end.getTime())&&I("span",{key:"end-date-group",class:p.timeExtentGroup},I("span",{key:"end-date",class:p.timeExtentDate},this._formatDate(o.end)),e.time&&I("span",{key:"end-time",class:p.timeExtentTime},this._formatTime(o.end)))]):null}renderBookmarkButton(t){const{disabled:e}=this,{timeExtent:o}=t,{capabilities:s}=this.viewModel,i=this._getBookmarkTitle(t),{thumbnail:r}=t,a=I("div",{class:this.classes(p.bookmarkImageContainer,r&&r.url?p.bookmarkImageContainerHasImage:null)},this.renderBookmarkImage(t)||this.renderBookmarkImageIcon()),n=s.time&&o?I("span",{key:"time-extent",class:p.bookmarkTimeExtent},this.renderBookmarkTimeExtent(t)):null;return I("button",{disabled:e,key:"bookmark-button",class:p.bookmarkButton,bind:this,"data-bookmark":t,onclick:this._goToBookmark,type:"button"},a,I("div",{class:p.bookmarkLabel},I("span",{key:"bookmark-title",class:p.bookmarkName},i),n))}renderBookmark(t){const{activeBookmark:e}=this.viewModel,o={[p.bookmarkActive]:e===t},s=this.editingEnabled?this.renderEditContainer(t):null,i={[T]:t.uid},r=this.editingEnabled?this.renderDragHandle(t):null;return I("li",{key:t,class:this.classes(p.bookmark,o),...i},r,this.renderBookmarkButton(t),s)}renderEditingBookmarkName(t){const{messages:e,_userState:o,disabled:s}=this,i="name-required"===o?.validationState;return I("label",{class:this.classes({[p.authoringLabel]:!0,[p.authoringLabelStartPadding]:!!this.visibleElements?.thumbnail})},e?.title,i?I("strong",null,e?.invalidTitle):null,I("input",{required:!0,disabled:s,bind:this,class:this.classes(p.esriInput,i?p.authoringInputInvalid:null),type:"text",value:t.name,afterCreate:this._storeEditInput,afterUpdate:this._focusEditInput,"data-bookmark":t,"data-node-ref":"_editInputNode",placeholder:e?.titlePlaceholder}))}renderEditingBookmarkUrlActions(){const{messagesCommon:t,disabled:e}=this;return I("div",{class:p.authoringActions},I("input",{type:"button",disabled:e,value:t?.back,class:this.classes(p.esriButton,p.esriButtonTertiary),onclick:this._closeUrlEditBookmarkForm,bind:this}),I("input",{class:p.esriButton,disabled:e,type:"submit",value:t?.add}))}renderEditingBookmarkActions(){const{messagesCommon:t,disabled:e}=this,o=this._userState?.bookmark;return I("div",{class:p.authoringActions},I("input",{type:"button",disabled:e,value:t?.delete,class:this.classes(p.esriButton,p.esriButtonTertiary,p.authoringDeleteButton),"data-bookmark":o,onclick:this._deleteBookmark,bind:this}),I("input",{disabled:e,type:"button",value:t?.cancel,class:this.classes(p.esriButton,p.esriButtonTertiary),onclick:this._closeEditBookmarkForm,bind:this}),I("input",{class:p.esriButton,disabled:e,type:"submit",value:t?.save}))}renderEditingBookmarkUrlInput(t){const{messages:e,_userState:o,disabled:s}=this,i=t.thumbnail?.url,r=i&&x.test(i)?i:void 0,a="absolute-url-required"===o?.validationState;return I("label",{class:this.classes({[p.authoringLabel]:!0,[p.authoringLabelStartPadding]:!!this.visibleElements?.thumbnail})},a?I("strong",null,e?.invalidImageUrl):null,I("input",{required:!0,disabled:s,bind:this,class:this.classes(p.esriInput,a?p.authoringInputInvalid:null),type:"text",value:r,afterCreate:this._storeUrlEditInput,afterUpdate:this._focusUrlEditInput,"data-bookmark":t,"data-node-ref":"_urlEditInputNode",title:e?.imageUrlTooltip,placeholder:e?`https://<${e.imageUrlPlaceholder}>`:void 0}))}renderEditingBookmarkUrl(t){if(!t)return null;const e={[T]:t.uid};return I("li",{key:"edit-bookmark-url-form",class:p.authoringCard,...e},I("form",{class:p.authoringForm,disabled:this.disabled,onsubmit:this._editBookmarkUrlSubmit,bind:this},this.renderEditingBookmarkUrlInput(t),this.renderEditingBookmarkUrlActions()))}renderEditingBookmark(t){if(!t)return null;const e={[T]:t.uid},{capabilities:o}=this.viewModel,s=o.time?I("div",{key:"edit-bookmark-time-container",class:p.timeExtentContainer},this.renderBookmarkTimeSwitch(t),this._editIncludeTimeExtent&&this.renderBookmarkTimeExtent(t)):null;return I("li",{key:"edit-bookmark-form",class:p.authoringCard,...e},I("form",{class:p.authoringForm,disabled:this.disabled,onsubmit:this._editBookmarkSubmit,bind:this},I("div",{class:p.authoringContainer},this.visibleElements.thumbnail?I("div",{class:p.bookmarkImageContainer},this.renderBookmarkImage(t),this._editMenu.render()):null,this.renderEditingBookmarkName(t)),s,this.renderEditingBookmarkActions()))}renderAddingBookmarkName(){const{_userState:t,messages:e,disabled:o}=this,s="name-required"===t?.validationState;return I("label",{class:this.classes({[p.authoringLabel]:!0,[p.authoringLabelStartPadding]:!0})},e?.title,s?I("strong",null,e?.invalidTitle):null,I("input",{required:!0,disabled:o,bind:this,class:this.classes(p.esriInput,s?p.authoringInputInvalid:null),type:"text",afterCreate:this._storeAddInput,afterUpdate:this._focusAddInput,"data-node-ref":"_addInputNode",value:"",placeholder:e?.titlePlaceholder}))}renderAddingBookmarkActions(){const{messagesCommon:t,disabled:e}=this;return I("div",{class:this.classes(p.authoringActions)},I("input",{type:"button",disabled:e,value:t?.cancel,class:this.classes(p.esriButton,p.esriButtonTertiary,p.authoringCancelButton),onclick:this._endAddBookmark.bind(this),bind:this}),I("input",{class:p.esriButton,disabled:e,type:"submit",value:t?.add}))}renderAddingBookmark(){return I("div",{key:"add-bookmark-form",class:p.authoringCard},I("form",{class:p.authoringForm,onsubmit:this._addBookmarkSubmit,bind:this},this.renderAddingBookmarkName(),this.renderAddingBookmarkActions()))}_setTooltipReference(t,e){this._tooltipReferenceMap.set(e.uid,t),this.scheduleRender()}_getBookmarkTitle(t){return(t?.name||this.messagesCommon?.untitled)??""}_formatDate(t){return t?l(t,u("short-date")):""}_formatTime(t){return t?l(t,u("long-time")):""}_dragHandleBlur(){this._selectedSortUid=null,this.scheduleRender()}_dragHandleKeydown(t){const{_sortableSavedItems:e}=this,s=["ArrowDown","ArrowUp","Escape","Tab"," ","Enter"],i=o(t);if(!s.includes(i))return;const{_sortable:r,_selectedSortUid:a}=this;if(!r)return;const n=r.toArray(),d=t.target.getAttribute(T),l=n.indexOf(d);if(f(i)){const t=a&&a===d;return this._selectedSortUid=t?null:d,this._sortableSavedItems=t?[]:r.toArray(),void this.scheduleRender()}if("Tab"===i)return this._selectedSortUid=null,void this.scheduleRender();if("Escape"===i&&0!==e.length)return t.stopPropagation(),this._selectedSortUid=null,this._updateSortItems(e,r,d),void this.scheduleRender();if(-1===l||!a)return;const u="ArrowUp"===i?l-1:l+1;u>=n.length||u<=-1||(S(n,l,u),this._updateSortItems(n,r,d))}_updateSortItems(t,e,o){e.sort(t),this._sortBookmarks(e),this._focusSortUid=o,this._selectedSortUid=o}_focusDragHandle(t){const e=M(t);if(!e)return;this._setTooltipReference(t,e);const{_focusSortUid:o}=this;if(!t||!o)return;t.getAttribute(T)===o&&(t.focus(),this._focusSortUid=null)}_toggleSorting(){const{_sortable:t,_sortableNode:e,editingEnabled:o,disabled:s}=this;if(e)if(t)t.option("disabled",s||!o);else{const t=y.create(e,{dataIdAttr:T,handle:`.${p.bookmarkDragHandle}`,group:w,disabled:s||!o,onSort:()=>this._sortBookmarks(t)});this._sortable=t}}_sortNodeCreated(t){this._sortableNode=t,this._toggleSorting()}_sortBookmarks(t){const{bookmarks:e}=this.viewModel;if(!e)return;const o=t.toArray();e.sort(((t,e)=>{const s=o.indexOf(t.uid),i=o.indexOf(e.uid);return s>i?1:s<i?-1:0}))}_destroySortable(){const{_sortable:t}=this;t&&t.destroy(),this._sortable=null}_endAddBookmark(){this._focusAddBookmarkButton=!0,this.endAddBookmark()}_bookmarksInitialized(){const t="bookmarks-init";this.removeHandles(t),this.addHandles(r((()=>this.viewModel?.bookmarks),"change",(()=>this._bookmarksChanged())),t)}_bookmarksChanged(){const t="bookmarks-change",{bookmarks:e}=this.viewModel;this.removeHandles(t);const o=e.map((t=>s((()=>[t?.name,t?.thumbnail?.url]),(()=>this.scheduleRender()))));this.addHandles(o.toArray(),t),this.scheduleRender()}_showEditBookmarkForm(t){const e=M(t.currentTarget);e&&(this._editIncludeTimeExtent=!!e.timeExtent,this._focusEditInputBox=!0,this._userState=new h({bookmark:e,state:"edit"}),this.viewModel.goTo(e),this.scheduleRender())}_closeUrlEditBookmarkForm(){this._focusEditInputBox=!0,this._userState&&(this._userState.state="edit")}_closeEditBookmarkForm(){this._userState=null}_addBookmarkSubmit(t){t.preventDefault();const{_addInputNode:e,_userState:o}=this;if(!o)return;const s=e?e.value.trim():null;s?(o.loading=!0,this.viewModel.createBookmark().then((t=>{t.name=s,this.viewModel.bookmarks.add(t),this._endAddBookmark()}))):o.validationState="name-required"}async _editBookmarkAndClose(t,e){const{viewModel:o}=this;await o.editBookmark(t,{...o.defaultEditOptions,...e}),this._closeEditBookmarkForm()}_editBookmarkSubmit(t){t.preventDefault();const{_editInputNode:e,_userState:o,_editIncludeTimeExtent:s}=this;if(!o?.bookmark||!o.editedBookmark)return;const i=e&&e.value.trim();i?(o.bookmark.name=i,o.bookmark.thumbnail=o.editedBookmark.thumbnail,s||(o.bookmark.timeExtent=null),this._editBookmarkAndClose(o.bookmark,{takeScreenshot:!1,captureTimeExtent:s})):o.validationState="name-required"}_storeAddBookmarkButton(t){this._addBookmarkButtonNode=t,this._focusAddBookmark()}_storeEditInput(t){this._editInputNode=t,this._focusEditInput()}_storeAddInput(t){this._addInputNode=t,this._focusAddInput()}_storeUrlEditInput(t){this._urlEditInputNode=t,this._focusUrlEditInput()}_focusUrlEditInput(){this._urlEditInputNode&&this._focusUrlEditInputBox&&(this._focusUrlEditInputBox=!1,this._urlEditInputNode.focus())}_focusAddInput(){this._addInputNode&&this._focusAddInputBox&&(this._focusAddInputBox=!1,this._addInputNode.focus())}_focusAddBookmark(){this._addBookmarkButtonNode&&this._focusAddBookmarkButton&&(this._focusAddBookmarkButton=!1,this._addBookmarkButtonNode.focus())}_focusEditInput(){this._editInputNode&&this._focusEditInputBox&&(this._focusEditInputBox=!1,this._editInputNode.focus())}_deleteBookmark(t){const e=M(t.currentTarget);e&&this.viewModel.bookmarks.remove(e)}_goToBookmark(t){const e=M(t.currentTarget);e&&(this.endAddBookmark(),this._closeEditBookmarkForm(),this.viewModel.goTo(e))}async _refreshThumbnail(){const{_userState:t,_editMenu:e,viewModel:o}=this;t&&(t.validationState=void 0,await o.editBookmark(t.editedBookmark,{takeScreenshot:!0,captureViewpoint:!1,captureRotation:!1,captureScale:!1,captureTimeExtent:!1}),e.open=!1,this._focusEditInputBox=!0,this.scheduleRender())}_removeThumbnail(){const{_userState:t,_editMenu:e}=this;t?.editedBookmark&&(t.editedBookmark.thumbnail=null,t.validationState=void 0,e.open=!1,this._focusEditInputBox=!0,this.scheduleRender())}_startUseImageUrl(){this._userState&&(this._userState.state="edit-thumbnail"),this._editMenu.open=!1,this._focusUrlEditInputBox=!0,this.scheduleRender()}_editBookmarkUrlSubmit(t){t.preventDefault();const{_urlEditInputNode:e,_userState:o}=this;if(!e||!o)return;const s=e.value;x.test(s)?(s&&o.editedBookmark&&(o.editedBookmark.thumbnail=new m({url:s})),this._closeUrlEditBookmarkForm()):o.validationState="absolute-url-required"}};function M(t){return t["data-bookmark"]}t([a()],C.prototype,"_editIncludeTimeExtent",void 0),t([a({type:h})],C.prototype,"_userState",void 0),t([a({readOnly:!0})],C.prototype,"_editMenuItems",null),t([a({readOnly:!0})],C.prototype,"_editMenu",null),t([a()],C.prototype,"defaultCreateOptions",null),t([a()],C.prototype,"defaultEditOptions",null),t([a()],C.prototype,"bookmarks",null),t([a()],C.prototype,"disabled",void 0),t([a()],C.prototype,"editingEnabled",void 0),t([a()],C.prototype,"headingLevel",void 0),t([a()],C.prototype,"goToOverride",null),t([a()],C.prototype,"iconClass",void 0),t([a()],C.prototype,"icon",void 0),t([a()],C.prototype,"label",null),t([a(),v("esri/widgets/Bookmarks/t9n/Bookmarks")],C.prototype,"messages",void 0),t([a(),v("esri/t9n/common")],C.prototype,"messagesCommon",void 0),t([a(),v("esri/core/t9n/Units")],C.prototype,"messagesUnits",void 0),t([a()],C.prototype,"uiStrings",void 0),t([a()],C.prototype,"view",null),t([a({type:c}),E(["select-bookmark","bookmark-edit","bookmark-select"])],C.prototype,"viewModel",void 0),t([a()],C.prototype,"visibleElements",void 0),t([n("visibleElements")],C.prototype,"castVisibleElements",null),t([a()],C.prototype,"endAddBookmark",null),t([a()],C.prototype,"startAddBookmark",null),C=t([d(U)],C);const N=C;export{N as default};
5
+ import{_ as t}from"../chunks/tslib.es6.js";import{isSome as e}from"../core/arrayUtils.js";import{eventKey as o}from"../core/events.js";import{watch as s,initial as i,on as r}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import{cast as n}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import{formatDate as l,convertDateFormatToIntlOptions as u}from"../intl/date.js";import{SlideThumbnail as m}from"../webdoc/support/SlideThumbnail.js";import k from"./Widget.js";import h from"./Bookmarks/BookmarksUserState.js";import c from"./Bookmarks/BookmarksViewModel.js";import{CSS as p}from"./Bookmarks/css.js";import b from"./FeatureTable/Grid/support/ButtonMenu.js";import _ from"./FeatureTable/Grid/support/ButtonMenuItem.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{Heading as B}from"./support/Heading.js";import{isActivationKey as f}from"./support/widgetUtils.js";import{messageBundle as v}from"./support/decorators/messageBundle.js";import{vmEvent as E}from"./support/decorators/vmEvent.js";import{tsx as I}from"./support/jsxFactory.js";import y from"sortablejs";function S(t,e,o){t.splice(o,0,t.splice(e,1)[0])}const w="bookmarks",T="data-bookmark-uid",A={addBookmark:!0,thumbnail:!0,time:!0},x=/^https:\/\/.*/i,U="esri.widgets.Bookmarks";let C=class extends k{constructor(t,e){super(t,e),this._tooltipReferenceMap=new Map,this._addInputNode=null,this._editInputNode=null,this._urlEditInputNode=null,this._addBookmarkButtonNode=null,this._focusAddBookmarkButton=!1,this._focusEditInputBox=!1,this._focusAddInputBox=!1,this._focusUrlEditInputBox=!1,this._sortable=null,this._sortableNode=null,this._focusSortUid=null,this._selectedSortUid=null,this._sortableSavedItems=[],this._editIncludeTimeExtent=void 0,this._userState=null,this.disabled=!1,this.editingEnabled=!1,this.headingLevel=2,this.iconClass=p.widgetIcon,this.icon=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.viewModel=new c,this.visibleElements={...A}}initialize(){this.addHandles([s((()=>this.viewModel?.bookmarks),(()=>this._bookmarksInitialized()),i),s((()=>this.editingEnabled),(()=>this._toggleSorting()),i)])}destroy(){this.removeAllHandles(),this._destroySortable(),this._editMenu.destroy(),this._tooltipReferenceMap.clear()}loadDependencies(){return g({label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}get _editMenuItems(){const{messages:t,_userState:o}=this,s=o?.editedBookmark?.thumbnail?.url;return[new _({label:t?.menu.refreshThumbnail,iconClass:p.iconRefresh,clickFunction:()=>this._refreshThumbnail()}),new _({label:s&&x.test(s)?t?.menu.editImageUrl:t?.menu.useImageUrl,iconClass:p.iconLink,clickFunction:()=>this._startUseImageUrl()}),s?new _({label:t?.menu.removeThumbnail,iconClass:p.iconRemove,clickFunction:()=>this._removeThumbnail()}):null].filter(e)}get _editMenu(){const{_editMenuItems:t,messages:e,disabled:o}=this,s=this._get("_editMenu");s&&s.destroy();const i=new b({disabled:o,iconClass:p.iconHandleHorizontal,label:e?.menu.label});return i.items=t,i}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(t){this.viewModel.defaultCreateOptions=t}get defaultEditOptions(){return this.viewModel.defaultEditOptions}set defaultEditOptions(t){this.viewModel.defaultEditOptions=t}get bookmarks(){return this.viewModel.bookmarks}set bookmarks(t){this.viewModel.bookmarks=t}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(t){this.viewModel.goToOverride=t}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}castVisibleElements(t){return{...A,...t}}endAddBookmark(){this._userState=null}goTo(t){return this.viewModel.goTo(t)}render(){const{state:t}=this.viewModel,e="loading"===t?this.renderLoading():this.renderBookmarks();return I("div",{class:this.classes(p.base,p.esriWidget,{[p.esriWidgetDisabled]:this.disabled})},e)}startAddBookmark(){this._userState=new h({state:"add"}),this._focusAddInputBox=!0,this.scheduleRender()}renderBookmarkTooltips(t){return t.toArray().map((t=>this.renderBookmarkTooltip(t)))??[]}renderBookmarkTooltip(t){const{_tooltipReferenceMap:e,messagesCommon:o}=this,s=this._getBookmarkTitle(t),i=`${o?.dragHandleTitle} ${s}`;return t?I("calcite-tooltip",{key:`tooltip-${t.uid}`,label:i,referenceElement:e.get(t.uid)},i):null}renderLoading(){return I("div",{class:p.loaderContainer,key:"loader",tabIndex:this.disabled?-1:void 0},I("div",{class:p.loader}))}renderNoBookmarksContainer(){const{messages:t,disabled:e}=this;return I("div",{class:p.noBookmarksContainer,key:"no-bookmarks",tabIndex:e?-1:void 0},I("span",{"aria-hidden":"true",class:this.classes(p.noBookmarksIcon,p.widgetIcon)}),I(B,{level:this.headingLevel,class:this.classes(p.header,p.noBookmarksHeader)},t?.noBookmarksHeading),I("p",{class:p.noBookmarksDescription},t?.noBookmarksDescription))}renderAddBookmarkLoading(){return I("div",{key:"adding-bookmark",class:p.addingBookmark},I("span",{"aria-hidden":"true",class:this.classes(p.loading,p.rotating)}),this.messages?.addingBookmark)}renderBookmarkItems(t){if(!t)return[];const{_userState:e,editingEnabled:o}=this;return t.map((t=>o&&t&&e&&("edit"===e.state||"edit-thumbnail"===e.state)&&e.bookmark===t?"edit-thumbnail"===e.state?this.renderEditingBookmarkUrl(e.editedBookmark):this.renderEditingBookmark(e.editedBookmark):this.renderBookmark(t))).toArray()}renderBookmarksContainer(t){const{_userState:e,editingEnabled:o,disabled:s}=this,i="add"===e?.state,r=o&&!i?this.renderAddBookmarkButton():null,a=o?i&&e.loading?this.renderAddBookmarkLoading():"add"===e?.state?this.renderAddingBookmark():null:null;return[I("ul",{key:"bookmark-list","aria-label":this.messages?.widgetLabel,class:this.classes(p.bookmarkList,{[p.bookmarkListSortable]:this.editingEnabled}),afterCreate:this._sortNodeCreated,afterRemoved:this._destroySortable,"data-node-ref":"_sortableNode",bind:this,tabIndex:s?-1:void 0},this.renderBookmarkItems(t)),r,a]}renderAddBookmarkButton(){return this.visibleElements.addBookmark?I("div",{key:"add-bookmark-item",class:p.addBookmark},I("button",{class:this.classes(p.esriButton,p.esriButtonTertiary,p.addBookmarkButton),disabled:this.disabled,onclick:this.startAddBookmark,afterCreate:this._storeAddBookmarkButton,afterUpdate:this._storeAddBookmarkButton,"data-node-ref":"_addBookmarkButtonNode",bind:this,type:"button"},I("span",{"aria-hidden":"true",class:this.classes(p.addBookmarkIcon,p.iconPlus)}),this.messages?.addBookmark)):null}renderBookmarks(){const{bookmarks:t}=this.viewModel,e=t&&t.filter(Boolean),o=e&&e.length,s=o||this.editingEnabled?this.renderBookmarksContainer(e):null;return[o?null:this.renderNoBookmarksContainer(),s,this.renderBookmarkTooltips(t)]}renderEditContainer(t){const{messagesCommon:e,disabled:o}=this,s=this._getBookmarkTitle(t);return I("div",{class:p.bookmarkEditButtonContainer,key:"edit-container"},I("button",{disabled:o,title:`${e?.edit} ${s}`,"aria-label":`${e?.edit} ${s}`,"data-bookmark":t,onclick:this._showEditBookmarkForm,bind:this,class:p.bookmarkEditButton,type:"button"},I("span",{"aria-hidden":"true",class:p.iconEdit})))}renderDragHandle(t){const{messagesCommon:e,disabled:o}=this,s=this._getBookmarkTitle(t),i={[T]:t.uid};return I("div",{role:"button",tabIndex:o?-1:0,key:"drag-handle",bind:this,class:p.bookmarkDragHandle,onkeydown:this._dragHandleKeydown,"data-bookmark":t,afterCreate:this._focusDragHandle,afterUpdate:this._focusDragHandle,onblur:this._dragHandleBlur,"aria-pressed":this._selectedSortUid===t.uid?"true":"false","aria-label":`${e?.dragHandleTitle} ${s}`,...i},I("span",{"aria-hidden":"true",class:this.classes(p.bookmarkDragHandleIcon,p.iconHandle)}))}renderBookmarkImageIcon(){return I("span",{"aria-hidden":"true",class:this.classes(p.bookmarkIcon,p.widgetIcon)})}renderBookmarkImage(t){const{visibleElements:e}=this,{thumbnail:o}=t,s=o&&o.url||"";return e.thumbnail&&s?I("img",{src:s,alt:"",class:p.bookmarkImage}):null}renderBookmarkTimeSwitch(t){const{messages:e,disabled:o}=this,{timeExtent:s}=t,{view:i}=this.viewModel;return i?.timeExtent??s?I("calcite-label",{layout:"inline-space-between"},e?.includeTimeExtent,I("calcite-switch",{scale:"s",disabled:o,checked:!!s,onCalciteSwitchChange:t=>{const e=t.currentTarget;this._editIncludeTimeExtent=!!e.checked}})):null}renderBookmarkTimeExtent(t){const{visibleElements:e}=this,{timeExtent:o}=t;return o?I("span",{class:p.timeExtent},[null!=o.start&&I("span",{key:"start-date-group",class:p.timeExtentGroup},I("span",{key:"start-date",class:p.timeExtentDate},this._formatDate(o.start)),e.time&&I("span",{key:"start-time",class:p.timeExtentTime},this._formatTime(o.start))),null!=o.end&&(null==o.start||o.start.getTime()!==o.end.getTime())&&I("span",{key:"end-date-group",class:p.timeExtentGroup},I("span",{key:"end-date",class:p.timeExtentDate},this._formatDate(o.end)),e.time&&I("span",{key:"end-time",class:p.timeExtentTime},this._formatTime(o.end)))]):null}renderBookmarkButton(t){const{disabled:e}=this,{timeExtent:o}=t,{capabilities:s}=this.viewModel,i=this._getBookmarkTitle(t),{thumbnail:r}=t,a=I("div",{class:this.classes(p.bookmarkImageContainer,r&&r.url?p.bookmarkImageContainerHasImage:null)},this.renderBookmarkImage(t)||this.renderBookmarkImageIcon()),n=s.time&&o?I("span",{key:"time-extent",class:p.bookmarkTimeExtent},this.renderBookmarkTimeExtent(t)):null;return I("button",{disabled:e,key:"bookmark-button",class:p.bookmarkButton,bind:this,"data-bookmark":t,onclick:this._goToBookmark,type:"button"},a,I("div",{class:p.bookmarkLabel},I("span",{key:"bookmark-title",class:p.bookmarkName},i),n))}renderBookmark(t){const{activeBookmark:e}=this.viewModel,o={[p.bookmarkActive]:e===t},s=this.editingEnabled?this.renderEditContainer(t):null,i={[T]:t.uid},r=this.editingEnabled?this.renderDragHandle(t):null;return I("li",{key:t,class:this.classes(p.bookmark,o),...i},r,this.renderBookmarkButton(t),s)}renderEditingBookmarkName(t){const{messages:e,_userState:o,disabled:s}=this,i="name-required"===o?.validationState;return I("label",{class:this.classes({[p.authoringLabel]:!0,[p.authoringLabelStartPadding]:!!this.visibleElements?.thumbnail})},e?.title,i?I("strong",null,e?.invalidTitle):null,I("input",{required:!0,disabled:s,bind:this,class:this.classes(p.esriInput,i?p.authoringInputInvalid:null),type:"text",value:t.name,afterCreate:this._storeEditInput,afterUpdate:this._focusEditInput,"data-bookmark":t,"data-node-ref":"_editInputNode",placeholder:e?.titlePlaceholder}))}renderEditingBookmarkUrlActions(){const{messagesCommon:t,disabled:e}=this;return I("div",{class:p.authoringActions},I("input",{type:"button",disabled:e,value:t?.back,class:this.classes(p.esriButton,p.esriButtonTertiary),onclick:this._closeUrlEditBookmarkForm,bind:this}),I("input",{class:p.esriButton,disabled:e,type:"submit",value:t?.add}))}renderEditingBookmarkActions(){const{messagesCommon:t,disabled:e}=this,o=this._userState?.bookmark;return I("div",{class:p.authoringActions},I("input",{type:"button",disabled:e,value:t?.delete,class:this.classes(p.esriButton,p.esriButtonTertiary,p.authoringDeleteButton),"data-bookmark":o,onclick:this._deleteBookmark,bind:this}),I("input",{disabled:e,type:"button",value:t?.cancel,class:this.classes(p.esriButton,p.esriButtonTertiary),onclick:this._closeEditBookmarkForm,bind:this}),I("input",{class:p.esriButton,disabled:e,type:"submit",value:t?.save}))}renderEditingBookmarkUrlInput(t){const{messages:e,_userState:o,disabled:s}=this,i=t.thumbnail?.url,r=i&&x.test(i)?i:void 0,a="absolute-url-required"===o?.validationState;return I("label",{class:this.classes({[p.authoringLabel]:!0,[p.authoringLabelStartPadding]:!!this.visibleElements?.thumbnail})},a?I("strong",null,e?.invalidImageUrl):null,I("input",{required:!0,disabled:s,bind:this,class:this.classes(p.esriInput,a?p.authoringInputInvalid:null),type:"text",value:r,afterCreate:this._storeUrlEditInput,afterUpdate:this._focusUrlEditInput,"data-bookmark":t,"data-node-ref":"_urlEditInputNode",title:e?.imageUrlTooltip,placeholder:e?`https://<${e.imageUrlPlaceholder}>`:void 0}))}renderEditingBookmarkUrl(t){if(!t)return null;const e={[T]:t.uid};return I("li",{key:"edit-bookmark-url-form",class:p.authoringCard,...e},I("form",{class:p.authoringForm,disabled:this.disabled,onsubmit:this._editBookmarkUrlSubmit,bind:this},this.renderEditingBookmarkUrlInput(t),this.renderEditingBookmarkUrlActions()))}renderEditingBookmark(t){if(!t)return null;const e={[T]:t.uid},{capabilities:o}=this.viewModel,s=o.time?I("div",{key:"edit-bookmark-time-container",class:p.timeExtentContainer},this.renderBookmarkTimeSwitch(t),this._editIncludeTimeExtent&&this.renderBookmarkTimeExtent(t)):null;return I("li",{key:"edit-bookmark-form",class:p.authoringCard,...e},I("form",{class:p.authoringForm,disabled:this.disabled,onsubmit:this._editBookmarkSubmit,bind:this},I("div",{class:p.authoringContainer},this.visibleElements.thumbnail?I("div",{class:p.bookmarkImageContainer},this.renderBookmarkImage(t),this._editMenu.render()):null,this.renderEditingBookmarkName(t)),s,this.renderEditingBookmarkActions()))}renderAddingBookmarkName(){const{_userState:t,messages:e,disabled:o}=this,s="name-required"===t?.validationState;return I("label",{class:p.authoringLabel},e?.title,s?I("strong",null,e?.invalidTitle):null,I("input",{required:!0,disabled:o,bind:this,class:this.classes(p.esriInput,s?p.authoringInputInvalid:null),type:"text",afterCreate:this._storeAddInput,afterUpdate:this._focusAddInput,"data-node-ref":"_addInputNode",value:"",placeholder:e?.titlePlaceholder}))}renderAddingBookmarkActions(){const{messagesCommon:t,disabled:e}=this;return I("div",{class:this.classes(p.authoringActions)},I("input",{type:"button",disabled:e,value:t?.cancel,class:this.classes(p.esriButton,p.esriButtonTertiary,p.authoringCancelButton),onclick:this._endAddBookmark.bind(this),bind:this}),I("input",{class:p.esriButton,disabled:e,type:"submit",value:t?.add}))}renderAddingBookmark(){return I("div",{key:"add-bookmark-form",class:p.authoringCard},I("form",{class:this.classes(p.authoringForm,p.authoringFormAdding),onsubmit:this._addBookmarkSubmit,bind:this},this.renderAddingBookmarkName(),this.renderAddingBookmarkActions()))}_setTooltipReference(t,e){this._tooltipReferenceMap.set(e.uid,t),this.scheduleRender()}_getBookmarkTitle(t){return(t?.name||this.messagesCommon?.untitled)??""}_formatDate(t){return t?l(t,u("short-date")):""}_formatTime(t){return t?l(t,u("long-time")):""}_dragHandleBlur(){this._selectedSortUid=null,this.scheduleRender()}_dragHandleKeydown(t){const{_sortableSavedItems:e}=this,s=["ArrowDown","ArrowUp","Escape","Tab"," ","Enter"],i=o(t);if(!s.includes(i))return;const{_sortable:r,_selectedSortUid:a}=this;if(!r)return;const n=r.toArray(),d=t.target.getAttribute(T),l=n.indexOf(d);if(f(i)){const t=a&&a===d;return this._selectedSortUid=t?null:d,this._sortableSavedItems=t?[]:r.toArray(),void this.scheduleRender()}if("Tab"===i)return this._selectedSortUid=null,void this.scheduleRender();if("Escape"===i&&0!==e.length)return t.stopPropagation(),this._selectedSortUid=null,this._updateSortItems(e,r,d),void this.scheduleRender();if(-1===l||!a)return;const u="ArrowUp"===i?l-1:l+1;u>=n.length||u<=-1||(S(n,l,u),this._updateSortItems(n,r,d))}_updateSortItems(t,e,o){e.sort(t),this._sortBookmarks(e),this._focusSortUid=o,this._selectedSortUid=o}_focusDragHandle(t){const e=M(t);if(!e)return;this._setTooltipReference(t,e);const{_focusSortUid:o}=this;if(!t||!o)return;t.getAttribute(T)===o&&(t.focus(),this._focusSortUid=null)}_toggleSorting(){const{_sortable:t,_sortableNode:e,editingEnabled:o,disabled:s}=this;if(e)if(t)t.option("disabled",s||!o);else{const t=y.create(e,{dataIdAttr:T,handle:`.${p.bookmarkDragHandle}`,group:w,disabled:s||!o,onSort:()=>this._sortBookmarks(t)});this._sortable=t}}_sortNodeCreated(t){this._sortableNode=t,this._toggleSorting()}_sortBookmarks(t){const{bookmarks:e}=this.viewModel;if(!e)return;const o=t.toArray();e.sort(((t,e)=>{const s=o.indexOf(t.uid),i=o.indexOf(e.uid);return s>i?1:s<i?-1:0}))}_destroySortable(){const{_sortable:t}=this;t&&t.destroy(),this._sortable=null}_endAddBookmark(){this._focusAddBookmarkButton=!0,this.endAddBookmark()}_bookmarksInitialized(){const t="bookmarks-init";this.removeHandles(t),this.addHandles(r((()=>this.viewModel?.bookmarks),"change",(()=>this._bookmarksChanged())),t)}_bookmarksChanged(){const t="bookmarks-change",{bookmarks:e}=this.viewModel;this.removeHandles(t);const o=e.map((t=>s((()=>[t?.name,t?.thumbnail?.url]),(()=>this.scheduleRender()))));this.addHandles(o.toArray(),t),this.scheduleRender()}_showEditBookmarkForm(t){const e=M(t.currentTarget);e&&(this._editIncludeTimeExtent=!!e.timeExtent,this._focusEditInputBox=!0,this._userState=new h({bookmark:e,state:"edit"}),this.viewModel.goTo(e),this.scheduleRender())}_closeUrlEditBookmarkForm(){this._focusEditInputBox=!0,this._userState&&(this._userState.state="edit")}_closeEditBookmarkForm(){this._userState=null}_addBookmarkSubmit(t){t.preventDefault();const{_addInputNode:e,_userState:o}=this;if(!o)return;const s=e?e.value.trim():null;s?(o.loading=!0,this.viewModel.createBookmark().then((t=>{t.name=s,this.viewModel.bookmarks.add(t),this._endAddBookmark()}))):o.validationState="name-required"}async _editBookmarkAndClose(t,e){const{viewModel:o}=this;await o.editBookmark(t,{...o.defaultEditOptions,...e}),this._closeEditBookmarkForm()}_editBookmarkSubmit(t){t.preventDefault();const{_editInputNode:e,_userState:o,_editIncludeTimeExtent:s}=this;if(!o?.bookmark||!o.editedBookmark)return;const i=e&&e.value.trim();i?(o.bookmark.name=i,o.bookmark.thumbnail=o.editedBookmark.thumbnail,s||(o.bookmark.timeExtent=null),this._editBookmarkAndClose(o.bookmark,{takeScreenshot:!1,captureTimeExtent:s})):o.validationState="name-required"}_storeAddBookmarkButton(t){this._addBookmarkButtonNode=t,this._focusAddBookmark()}_storeEditInput(t){this._editInputNode=t,this._focusEditInput()}_storeAddInput(t){this._addInputNode=t,this._focusAddInput()}_storeUrlEditInput(t){this._urlEditInputNode=t,this._focusUrlEditInput()}_focusUrlEditInput(){this._urlEditInputNode&&this._focusUrlEditInputBox&&(this._focusUrlEditInputBox=!1,this._urlEditInputNode.focus())}_focusAddInput(){this._addInputNode&&this._focusAddInputBox&&(this._focusAddInputBox=!1,this._addInputNode.focus())}_focusAddBookmark(){this._addBookmarkButtonNode&&this._focusAddBookmarkButton&&(this._focusAddBookmarkButton=!1,this._addBookmarkButtonNode.focus())}_focusEditInput(){this._editInputNode&&this._focusEditInputBox&&(this._focusEditInputBox=!1,this._editInputNode.focus())}_deleteBookmark(t){const e=M(t.currentTarget);e&&this.viewModel.bookmarks.remove(e)}_goToBookmark(t){const e=M(t.currentTarget);e&&(this.endAddBookmark(),this._closeEditBookmarkForm(),this.viewModel.goTo(e))}async _refreshThumbnail(){const{_userState:t,_editMenu:e,viewModel:o}=this;t&&(t.validationState=void 0,await o.editBookmark(t.editedBookmark,{takeScreenshot:!0,captureViewpoint:!1,captureRotation:!1,captureScale:!1,captureTimeExtent:!1}),e.open=!1,this._focusEditInputBox=!0,this.scheduleRender())}_removeThumbnail(){const{_userState:t,_editMenu:e}=this;t?.editedBookmark&&(t.editedBookmark.thumbnail=null,t.validationState=void 0,e.open=!1,this._focusEditInputBox=!0,this.scheduleRender())}_startUseImageUrl(){this._userState&&(this._userState.state="edit-thumbnail"),this._editMenu.open=!1,this._focusUrlEditInputBox=!0,this.scheduleRender()}_editBookmarkUrlSubmit(t){t.preventDefault();const{_urlEditInputNode:e,_userState:o}=this;if(!e||!o)return;const s=e.value;x.test(s)?(s&&o.editedBookmark&&(o.editedBookmark.thumbnail=new m({url:s})),this._closeUrlEditBookmarkForm()):o.validationState="absolute-url-required"}};function M(t){return t["data-bookmark"]}t([a()],C.prototype,"_editIncludeTimeExtent",void 0),t([a({type:h})],C.prototype,"_userState",void 0),t([a({readOnly:!0})],C.prototype,"_editMenuItems",null),t([a({readOnly:!0})],C.prototype,"_editMenu",null),t([a()],C.prototype,"defaultCreateOptions",null),t([a()],C.prototype,"defaultEditOptions",null),t([a()],C.prototype,"bookmarks",null),t([a()],C.prototype,"disabled",void 0),t([a()],C.prototype,"editingEnabled",void 0),t([a()],C.prototype,"headingLevel",void 0),t([a()],C.prototype,"goToOverride",null),t([a()],C.prototype,"iconClass",void 0),t([a()],C.prototype,"icon",void 0),t([a()],C.prototype,"label",null),t([a(),v("esri/widgets/Bookmarks/t9n/Bookmarks")],C.prototype,"messages",void 0),t([a(),v("esri/t9n/common")],C.prototype,"messagesCommon",void 0),t([a(),v("esri/core/t9n/Units")],C.prototype,"messagesUnits",void 0),t([a()],C.prototype,"uiStrings",void 0),t([a()],C.prototype,"view",null),t([a({type:c}),E(["select-bookmark","bookmark-edit","bookmark-select"])],C.prototype,"viewModel",void 0),t([a()],C.prototype,"visibleElements",void 0),t([n("visibleElements")],C.prototype,"castVisibleElements",null),t([a()],C.prototype,"endAddBookmark",null),t([a()],C.prototype,"startAddBookmark",null),C=t([d(U)],C);const N=C;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.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{makeHandle as e}from"../../core/handleUtils.js";import{applySome as s,removeMaybe as n}from"../../core/maybe.js";import{when as l,initial as a,watch as o,on as r,syncAndInitial as h}from"../../core/reactiveUtils.js";import{schedule as g}from"../../core/scheduling.js";import{truncateLocalTime as d,resetUTCDate as p,offsetDate as u}from"../../core/timeUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import m from"../../views/SceneView.js";import _ from"../../views/3d/environment/SunLighting.js";import f from"../../views/3d/environment/VirtualLighting.js";import{positionToTimezoneInfo as w}from"../../views/3d/support/earthUtils.js";import{dateTimeToSliderPos as S,sliderPosToDateTime as D,getSeasonFromDate as T,getNorthernHemisphereSeason as U,getSeasonDate as v,Hemisphere as P,calculatePlaySpeed as L}from"./support/daylightUtils.js";import{SliderWithDropdownViewModel as b}from"./support/SliderWithDropdownViewModel.js";import O from"../support/DatePickerViewModel.js";import{formatSliderLabel as E,getSunriseAndSunsetTimes as C}from"../support/timeWidgetUtils.js";let M=class extends i{constructor(t){super(t),this.view=null,this.datePickerViewModel=new O,this.timeSliderViewModel=new b({min:0,max:1439,values:[0],labelFormatFunction:E,inputFormatFunction:E}),this.lightingUpdateInterval=200,this._oldLighting=null,this.playSpeedMultiplier=1,this._lastTime=null,this._sunrise=null,this._sunset=null,this._cachedLightingDateUTC=new Date(0),this._cachedDisplayUTCOffset=0,this._firstInteraction=!0,this._lastLightingUpdate=0,this._lightingUpdateHandle=null}initialize(){this.handles.add([l((()=>this.view),(t=>t.when((()=>this._updateLighting()))),a),o((()=>s(this._lighting,(t=>"virtual"!==t.type?t.date:null))),(t=>this._scheduleLightingUpdate(t))),r((()=>this._lighting),"timezone-will-change",(t=>this._timezoneWillChange(t)),{onListenerAdd:()=>this._timezoneWillChange(null)}),o((()=>!0===s(this.view,(t=>t.stationary))),(()=>{(this.dayPlaying||this.yearPlaying)&&this._updateSunriseAndSunset()}),a),o((()=>{const t=this.timeSliderViewModel;return{vm:t,state:t.state,sliderPosition:this.timeSliderPosition}}),(({vm:t,state:i,sliderPosition:e})=>{"ready"===i&&t.setValue(0,e)})),o((()=>this.timeSliderViewModel?.utcOffset),(t=>{null!=t&&(this.utcOffset=t)})),o((()=>({utcOffset:this.utcOffset,sliderViewModel:this.timeSliderViewModel})),(({utcOffset:t,sliderViewModel:i})=>{i&&(i.utcOffset=t)}),h),o((()=>this.timeSliderViewModel.timezonePickerOpen),(()=>this.stopPlaying())),o((()=>this.timeSliderViewModel.values),(t=>this._setTimeSliderPosition(t?.[0]??0,{forceLightingUpdate:!1}))),o((()=>this.datePickerViewModel.value),(t=>{this.dayPlaying=!1,this.localDate=t})),o((()=>this.localDate),(t=>{this.datePickerViewModel.value.valueOf()!==t.getTime()&&this.datePickerViewModel.set("value",t)}))])}destroy(){this._cancelLightingUpdate(),this.view=null}get isSupported(){return null==this.view||"3d"===this.view.type}get utcOffset(){return this._cachedDisplayUTCOffset}set utcOffset(t){t!==this.utcOffset&&null!=this._lighting&&"virtual"!==this._lighting.type&&(this._lighting.displayUTCOffset=t,this._updateLighting())}get localDate(){return d(this._lightingDateDisplay)}set localDate(t){t.getTime()!==this.localDate.getTime()&&(this._lightingDateDisplay=p(this._lightingDateDisplay,t))}get timeSliderPosition(){return S(this._lightingDateDisplay)}set timeSliderPosition(t){this._setTimeSliderPosition(t,{forceLightingUpdate:!0})}_setTimeSliderPosition(t,i){Math.abs(t-this.timeSliderPosition)<=1/60||(this.stopPlaying(),this._enableDirectShadowsIfFirstInteraction(),i.forceLightingUpdate&&(this._cancelLightingUpdate(),this._updateLighting()),this._lightingDateDisplay=D(this._lightingDateDisplay,t))}_timezoneFromCamera(t,i){if(null==i||!t.cameraTrackingEnabled)return 0;const e=w([i.longitude,i.latitude]);return null==e?0:Math.round(e.hours+e.minutes/60+e.seconds/3600)}get directShadowsEnabled(){return s(this._lighting,(t=>t.directShadowsEnabled))??!1}set directShadowsEnabled(t){s(this._lighting,(i=>{i.directShadowsEnabled=t}))}get sunLightingEnabled(){return"sun"===this._lightingType}set sunLightingEnabled(t){const i=this._environment;if(t===this._get("sunLightingEnabled")||null==i)return;const e=i.lighting,s=this._oldLighting;this._oldLighting=e;const n={directShadowsEnabled:e.directShadowsEnabled,cameraTrackingEnabled:e.cameraTrackingEnabled},l=t?"sun":"virtual";let a;a=null!=s&&s.type===l?s:t?new _:new f,a.set(n),i.lighting=a,t||(this.timeSliderViewModel.timezonePickerOpen=!1)}set playingState(t){this.playingState!==t&&this.sunLightingEnabled&&(this._set("playingState",t),"none"!==t&&(this._updateSunriseAndSunset(),this._lastTime=Date.now(),this._play(),this._enableDirectShadowsIfFirstInteraction()))}get dayPlaying(){return"day"===this.playingState}set dayPlaying(t){t?this.playingState="day":this.dayPlaying&&(this.playingState="none")}get yearPlaying(){return"year"===this.playingState}set yearPlaying(t){t?this.playingState="year":this.yearPlaying&&(this.playingState="none")}get currentSeason(){return T(this.localDate,this._currentHemisphere)}set currentSeason(t){this.stopPlaying();const i=U(t,this._currentHemisphere);this.localDate=v(this.localDate,i,P.NORTHERN)}get _currentHemisphere(){const t=s(this.view,(t=>t.camera?.position?.latitude));return null==t||t>=0?P.NORTHERN:P.SOUTHERN}get _environment(){return s(this.view,(t=>t.environment))}get _lighting(){return s(this._environment,(t=>t.lighting))}get _lightingType(){return s(this._lighting,(t=>t.type))}get _lightingDateDisplay(){return u(this._cachedLightingDateUTC,this._cachedDisplayUTCOffset,"hours")}set _lightingDateDisplay(t){const i=this._lighting;if(null==i||!this.sunLightingEnabled||"virtual"===i.type)return;const e=u(t,-this._cachedDisplayUTCOffset,"hours");e.getTime()!==i.date.getTime()&&(i.date=e,this._updateLighting())}stopPlaying(){this.playingState="none"}toggleDayPlaying(){this.dayPlaying=!this.dayPlaying}toggleYearPlaying(){this.yearPlaying=!this.yearPlaying}toggleSunLightingEnabled(){this.stopPlaying(),this.sunLightingEnabled=!this.sunLightingEnabled}toggleDirectShadowsEnabled(){this.stopPlaying(),this.directShadowsEnabled=!this.directShadowsEnabled}_enableDirectShadowsIfFirstInteraction(){this._firstInteraction&&(this._firstInteraction=!1,this.directShadowsEnabled=!0)}_updateLighting(t){const i=Date.now();this._lastLightingUpdate=i;const{view:e}=this,s=this._lighting;if(null==e||null==s||"virtual"===s.type)return;const n=t||s.date,l=s.displayUTCOffset,a=null!==l?l:this._timezoneFromCamera(s,e.camera?.position);this._cachedLightingDateUTC.getTime()!==n.getTime()&&(this._cachedLightingDateUTC=new Date(n.getTime())),this._cachedDisplayUTCOffset!==a&&(this._cachedDisplayUTCOffset=a)}_timezoneWillChange(t){const i=this._lighting;if(null==i||"virtual"===i.type||!i.cameraTrackingEnabled)return;let e;if(t)e=t.timezoneOffset;else{if(null!=i.displayUTCOffset)return;e=_.calculateTimezoneOffset(i.positionTimezoneInfo)}i.displayUTCOffset=e,this._scheduleLightingUpdate()}_scheduleLightingUpdate(t){if(t&&(this._lightingUpdateHandle=n(this._lightingUpdateHandle)),this._lightingUpdateHandle)return;const i=Date.now()-this._lastLightingUpdate,s=this.lightingUpdateInterval-i;let l=null;const a=()=>{this._updateLighting(t),this._lightingUpdateHandle===l&&(this._lightingUpdateHandle=null)};if(s<=0)this._lightingUpdateHandle=l=g(a);else{const t=setTimeout(a,s);this._lightingUpdateHandle=l=e((()=>clearTimeout(t)))}}_cancelLightingUpdate(){this._lightingUpdateHandle=n(this._lightingUpdateHandle)}_play(){const t=this._lighting;if(null!=t&&this.sunLightingEnabled&&"virtual"!==t.type&&(this.dayPlaying||this.yearPlaying)){const i=Date.now()-(this._lastTime??0);if(this.dayPlaying){this._lastTime=Date.now();const e=L(this._sunrise,this._sunset,t.date)*this.playSpeedMultiplier/100*i;if(e>0){let i=new Date(t.date.getTime()+e);const s=t.displayUTCOffset??0;if(((i.getUTCHours()+s)%24+24)%24<((t.date.getUTCHours()+s)%24+24)%24){const s=864e5;i=new Date(t.date.getTime()+e-s)}t.date=i}}else{if(i>1e3){this._lastTime=Date.now();const i=(t.date.getUTCMonth()+1)%12,e=new Date(t.date.getTime());e.setUTCMonth(i),t.date=e}}requestAnimationFrame((()=>this._play()))}}_updateSunriseAndSunset(){const t=this._lighting;if(null==t||"virtual"===t.type||!this.sunLightingEnabled)return;const i=s(this.view,(t=>t.camera?.position));if(null==i)return;const{latitude:e,longitude:n}=i,{date:l,displayUTCOffset:a}=t,o=C(l,e,n,a);o&&(this._sunrise=new Date(o.sunrise),this._sunset=new Date(o.sunset))}};t([c({type:m})],M.prototype,"view",void 0),t([c({type:O,nonNullable:!0})],M.prototype,"datePickerViewModel",void 0),t([c({type:b,nonNullable:!0})],M.prototype,"timeSliderViewModel",void 0),t([c()],M.prototype,"isSupported",null),t([c()],M.prototype,"lightingUpdateInterval",void 0),t([c()],M.prototype,"utcOffset",null),t([c()],M.prototype,"localDate",null),t([c()],M.prototype,"timeSliderPosition",null),t([c()],M.prototype,"directShadowsEnabled",null),t([c()],M.prototype,"sunLightingEnabled",null),t([c({type:["none","day","year"],value:"none"})],M.prototype,"playingState",null),t([c()],M.prototype,"dayPlaying",null),t([c()],M.prototype,"yearPlaying",null),t([c()],M.prototype,"playSpeedMultiplier",void 0),t([c()],M.prototype,"currentSeason",null),t([c()],M.prototype,"_lastTime",void 0),t([c()],M.prototype,"_sunrise",void 0),t([c()],M.prototype,"_sunset",void 0),t([c()],M.prototype,"_cachedLightingDateUTC",void 0),t([c()],M.prototype,"_cachedDisplayUTCOffset",void 0),t([c()],M.prototype,"_firstInteraction",void 0),t([c()],M.prototype,"_currentHemisphere",null),t([c()],M.prototype,"_environment",null),t([c()],M.prototype,"_lighting",null),t([c()],M.prototype,"_lightingType",null),t([c()],M.prototype,"_lightingDateDisplay",null),M=t([y("esri.widgets.Daylight.DaylightViewModel")],M);const V=M;export{V as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{makeHandle as e}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{applySome as s,removeMaybe as l}from"../../core/maybe.js";import{when as a,initial as o,watch as r,on as h,syncAndInitial as g}from"../../core/reactiveUtils.js";import{schedule as d}from"../../core/scheduling.js";import{truncateLocalTime as p,isValidDate as u,resetUTCDate as c,offsetDate as y}from"../../core/timeUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../views/SceneView.js";import w from"../../views/3d/environment/SunLighting.js";import S from"../../views/3d/environment/VirtualLighting.js";import{positionToTimezoneInfo as D}from"../../views/3d/support/earthUtils.js";import{dateTimeToSliderPos as T,sliderPosToDateTime as v,getSeasonFromDate as U,getNorthernHemisphereSeason as P,getSeasonDate as L,Hemisphere as b,calculatePlaySpeed as O}from"./support/daylightUtils.js";import{SliderWithDropdownViewModel as E}from"./support/SliderWithDropdownViewModel.js";import C from"../support/DatePickerViewModel.js";import{formatSliderLabel as M,getSunriseAndSunsetTimes as j}from"../support/timeWidgetUtils.js";const V="esri.widgets.Daylight.DaylightViewModel";let H=class extends i{constructor(t){super(t),this.view=null,this.datePickerViewModel=new C,this.timeSliderViewModel=new E({min:0,max:1439,values:[0],labelFormatFunction:M,inputFormatFunction:M}),this.lightingUpdateInterval=200,this._oldLighting=null,this.playSpeedMultiplier=1,this._lastTime=null,this._sunrise=null,this._sunset=null,this._cachedLightingDateUTC=new Date(0),this._cachedDisplayUTCOffset=0,this._firstInteraction=!0,this._lastLightingUpdate=0,this._lightingUpdateHandle=null}initialize(){this.handles.add([a((()=>this.view),(t=>t.when((()=>this._updateLighting()))),o),r((()=>{const t=this._lighting;return"sun"===t?.type?I(t):null}),(t=>this._scheduleLightingUpdate(t))),h((()=>this._lighting),"timezone-will-change",(t=>this._timezoneWillChange(t)),{onListenerAdd:()=>this._timezoneWillChange(null)}),r((()=>!0===s(this.view,(t=>t.stationary))),(()=>{(this.dayPlaying||this.yearPlaying)&&this._updateSunriseAndSunset()}),o),r((()=>{const t=this.timeSliderViewModel;return{vm:t,state:t.state,sliderPosition:this.timeSliderPosition}}),(({vm:t,state:i,sliderPosition:e})=>{"ready"===i&&t.setValue(0,e)})),r((()=>this.timeSliderViewModel?.utcOffset),(t=>{null!=t&&(this.utcOffset=t)})),r((()=>({utcOffset:this.utcOffset,sliderViewModel:this.timeSliderViewModel})),(({utcOffset:t,sliderViewModel:i})=>{i&&(i.utcOffset=t)}),g),r((()=>this.timeSliderViewModel.timezonePickerOpen),(()=>this.stopPlaying())),r((()=>this.timeSliderViewModel.values),(t=>this._setTimeSliderPosition(t?.[0]??0,{forceLightingUpdate:!1}))),r((()=>this.datePickerViewModel.value),(t=>{this.dayPlaying=!1,this.localDate=t})),r((()=>this.localDate),(t=>{this.datePickerViewModel.value.valueOf()!==t.getTime()&&this.datePickerViewModel.set("value",t)}))])}destroy(){this._cancelLightingUpdate(),this.view=null}get isSupported(){return null==this.view||"3d"===this.view.type}get utcOffset(){return this._cachedDisplayUTCOffset}set utcOffset(t){t!==this.utcOffset&&null!=this._lighting&&"virtual"!==this._lighting.type&&(this._lighting.displayUTCOffset=t,this._updateLighting())}get localDate(){return p(this._lightingDateDisplay)}set localDate(t){u(t)&&t.getTime()!==this.localDate.getTime()&&(this._lightingDateDisplay=c(this._lightingDateDisplay,t))}get timeSliderPosition(){return T(this._lightingDateDisplay)}set timeSliderPosition(t){this._setTimeSliderPosition(t,{forceLightingUpdate:!0})}_setTimeSliderPosition(t,i){Math.abs(t-this.timeSliderPosition)<=1/60||(this.stopPlaying(),this._enableDirectShadowsIfFirstInteraction(),i.forceLightingUpdate&&(this._cancelLightingUpdate(),this._updateLighting()),this._lightingDateDisplay=v(this._lightingDateDisplay,t))}_timezoneFromCamera(t,i){if(null==i||!t.cameraTrackingEnabled)return 0;const e=D([i.longitude,i.latitude]);return null==e?0:Math.round(e.hours+e.minutes/60+e.seconds/3600)}get directShadowsEnabled(){return s(this._lighting,(t=>t.directShadowsEnabled))??!1}set directShadowsEnabled(t){s(this._lighting,(i=>{i.directShadowsEnabled=t}))}get sunLightingEnabled(){return"sun"===this._lightingType}set sunLightingEnabled(t){const i=this._environment;if(t===this._get("sunLightingEnabled")||null==i)return;const e=i.lighting,n=this._oldLighting;this._oldLighting=e;const s={directShadowsEnabled:e.directShadowsEnabled,cameraTrackingEnabled:e.cameraTrackingEnabled},l=t?"sun":"virtual";let a;a=null!=n&&n.type===l?n:t?new w:new S,a.set(s),i.lighting=a,t||(this.timeSliderViewModel.timezonePickerOpen=!1)}set playingState(t){this.playingState!==t&&this.sunLightingEnabled&&(this._set("playingState",t),"none"!==t&&(this._updateSunriseAndSunset(),this._lastTime=Date.now(),this._play(),this._enableDirectShadowsIfFirstInteraction()))}get dayPlaying(){return"day"===this.playingState}set dayPlaying(t){t?this.playingState="day":this.dayPlaying&&(this.playingState="none")}get yearPlaying(){return"year"===this.playingState}set yearPlaying(t){t?this.playingState="year":this.yearPlaying&&(this.playingState="none")}get currentSeason(){return U(this.localDate,this._currentHemisphere)}set currentSeason(t){this.stopPlaying();const i=P(t,this._currentHemisphere);this.localDate=L(this.localDate,i,b.NORTHERN)}get _currentHemisphere(){const t=s(this.view,(t=>t.camera?.position?.latitude));return null==t||t>=0?b.NORTHERN:b.SOUTHERN}get _environment(){return s(this.view,(t=>t.environment))}get _lighting(){return s(this._environment,(t=>t.lighting))}get _lightingType(){return s(this._lighting,(t=>t.type))}get _lightingDateDisplay(){return y(this._cachedLightingDateUTC,this._cachedDisplayUTCOffset,"hours")}set _lightingDateDisplay(t){const i=this._lighting;if(null==i||!this.sunLightingEnabled||"virtual"===i.type||!u(t))return;const e=I(i),n=y(t,-this._cachedDisplayUTCOffset,"hours");n.getTime()!==e.getTime()&&(i.date=n,this._updateLighting())}stopPlaying(){this.playingState="none"}toggleDayPlaying(){this.dayPlaying=!this.dayPlaying}toggleYearPlaying(){this.yearPlaying=!this.yearPlaying}toggleSunLightingEnabled(){this.stopPlaying(),this.sunLightingEnabled=!this.sunLightingEnabled}toggleDirectShadowsEnabled(){this.stopPlaying(),this.directShadowsEnabled=!this.directShadowsEnabled}_enableDirectShadowsIfFirstInteraction(){this._firstInteraction&&(this._firstInteraction=!1,this.directShadowsEnabled=!0)}_updateLighting(t){const i=Date.now();this._lastLightingUpdate=i;const{view:e}=this,n=this._lighting;if(null==e||null==n||"virtual"===n.type)return;t??=I(n);const s=n.displayUTCOffset,l=null!==s?s:this._timezoneFromCamera(n,e.camera?.position);this._cachedLightingDateUTC.getTime()!==t.getTime()&&(this._cachedLightingDateUTC=new Date(t.getTime())),this._cachedDisplayUTCOffset!==l&&(this._cachedDisplayUTCOffset=l)}_timezoneWillChange(t){const i=this._lighting;if(null==i||"virtual"===i.type||!i.cameraTrackingEnabled)return;let e;if(t)e=t.timezoneOffset;else{if(null!=i.displayUTCOffset)return;e=w.calculateTimezoneOffset(i.positionTimezoneInfo)}i.displayUTCOffset=e,this._scheduleLightingUpdate()}_scheduleLightingUpdate(t){if(t&&(this._lightingUpdateHandle=l(this._lightingUpdateHandle),!u(t)))return;if(this._lightingUpdateHandle)return;const i=Date.now()-this._lastLightingUpdate,n=this.lightingUpdateInterval-i;let s=null;const a=()=>{this._updateLighting(t),this._lightingUpdateHandle===s&&(this._lightingUpdateHandle=null)};if(n<=0)this._lightingUpdateHandle=s=d(a);else{const t=setTimeout(a,n);this._lightingUpdateHandle=s=e((()=>clearTimeout(t)))}}_cancelLightingUpdate(){this._lightingUpdateHandle=l(this._lightingUpdateHandle)}_play(){const t=this._lighting;if(null==t||!this.sunLightingEnabled||"virtual"===t.type)return;const i=I(t);if(this.dayPlaying||this.yearPlaying){const e=Date.now()-(this._lastTime??0);if(this.dayPlaying){this._lastTime=Date.now();const n=O(this._sunrise,this._sunset,i)*this.playSpeedMultiplier/100*e;if(n>0){let e=new Date(i.getTime()+n);const s=t.displayUTCOffset??0;if(((e.getUTCHours()+s)%24+24)%24<((i.getUTCHours()+s)%24+24)%24){const t=864e5;e=new Date(i.getTime()+n-t)}t.date=e}}else{if(e>1e3){this._lastTime=Date.now();const e=(i.getUTCMonth()+1)%12,n=new Date(i.getTime());n.setUTCMonth(e),t.date=n}}requestAnimationFrame((()=>this._play()))}}_updateSunriseAndSunset(){const t=this._lighting;if(null==t||"virtual"===t.type||!this.sunLightingEnabled)return;const i=s(this.view,(t=>t.camera?.position));if(null==i)return;const{latitude:e,longitude:n}=i,{date:l,displayUTCOffset:a}=t,o=j(l,e,n,a);o&&(this._sunrise=new Date(o.sunrise),this._sunset=new Date(o.sunset))}};function I(t){return u(t.date)||(n.getLogger(V).warn("Invalid date. Reverting to the current date/time."),t.date=new Date),t.date}t([m({type:f})],H.prototype,"view",void 0),t([m({type:C,nonNullable:!0})],H.prototype,"datePickerViewModel",void 0),t([m({type:E,nonNullable:!0})],H.prototype,"timeSliderViewModel",void 0),t([m()],H.prototype,"isSupported",null),t([m()],H.prototype,"lightingUpdateInterval",void 0),t([m()],H.prototype,"utcOffset",null),t([m()],H.prototype,"localDate",null),t([m()],H.prototype,"timeSliderPosition",null),t([m()],H.prototype,"directShadowsEnabled",null),t([m()],H.prototype,"sunLightingEnabled",null),t([m({type:["none","day","year"],value:"none"})],H.prototype,"playingState",null),t([m()],H.prototype,"dayPlaying",null),t([m()],H.prototype,"yearPlaying",null),t([m()],H.prototype,"playSpeedMultiplier",void 0),t([m()],H.prototype,"currentSeason",null),t([m()],H.prototype,"_lastTime",void 0),t([m()],H.prototype,"_sunrise",void 0),t([m()],H.prototype,"_sunset",void 0),t([m()],H.prototype,"_cachedLightingDateUTC",void 0),t([m()],H.prototype,"_cachedDisplayUTCOffset",void 0),t([m()],H.prototype,"_firstInteraction",void 0),t([m()],H.prototype,"_currentHemisphere",null),t([m()],H.prototype,"_environment",null),t([m()],H.prototype,"_lighting",null),t([m()],H.prototype,"_lightingType",null),t([m()],H.prototype,"_lightingDateDisplay",null),H=t([_(V)],H);const k=H;export{k as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{isEditableLayer as k}from"../../layers/support/editableLayers.js";import{getOwningPortalUrl as g,getEffectiveLayerCapabilities as v,isFeatureLayer as b}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as W}from"../../portal/support/urlUtils.js";import _ from"../Attachments/AttachmentsViewModel.js";import F from"./CreateFeaturesWorkflow.js";import C from"./CreateWorkflow.js";import{workflowDeprecation as E}from"./deprecationUtils.js";import I from"./UpdateWorkflow.js";import{whenEditorLayerView as U}from"./workflowUtils.js";import{formTemplateHasInvalidFields as A,unsupportedDateFieldTypes as O}from"../FeatureForm/featureFormUtils.js";import V from"../FeatureForm/FeatureFormViewModel.js";import j from"../FeatureTemplates/FeatureTemplatesViewModel.js";import M from"../Sketch/SketchViewModel.js";import T from"../Spinner/SpinnerViewModel.js";const S="esri.widgets.Editor.EditorViewModel",L=n.getLogger(S),P=["create","create-features","update"];function D(t,e,a){L.error(new i(t,e,a))}function G(t,e){return t?t.find((t=>t.layer===e)):void 0}let x=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new _({capabilities:{editing:!0}}),this.featureFormViewModel=new V,this.featureTemplatesViewModel=new j,this.sketchViewModel=new M({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new T,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{this.canGoBack&&await(this.activeWorkflow?.back(this.showDiscardEditsPrompt))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0||await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const s={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(s);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(s):this.startCreateFeaturesWorkflowAtFeatureCreation(s)})),c((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...P]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(L,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1==!!t.activeEditableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditableItem?.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(E(L,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(E(L,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(E(L,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():D("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasInvalidFormTemplate??!1)}itemHasUnsupportedFields(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasUnsupportedFields??!1)}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map,i=r?.editableLayers.toArray()??[],s=r?.allTables.toArray().filter(b)??[];await Promise.all(s.map((t=>t.load())));const o=s.filter((t=>k(t))),n=[...i.reverse(),...o.reverse()];if(!e||!i)return;const l=[],p=[];for(const a of n){const r=e.find((t=>t.layer===a)),i=r?l:p;if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)i.push(this._makeEditableItemForLayer(a.sublayers.at(t),!!r?.suspended))}else i.push(this._makeEditableItemForLayer(a,!!r?.suspended))}if(t.aborted)return;const c=this._editableItems;this._editableItems=new a(l.concat(p)),c.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&D("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return F.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return C.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return I.create(this,t,((t,e)=>this._applyEdits(t,e)))}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await g(t.url):null,s={returnServiceEditsOption:(!i||!W(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const a=await U(this.view,t).catch((()=>null));return r=await t.applyEdits(e,s),a&&await h((()=>!a.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{D("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=v(t),r=a?.operations,i=G(this.layerInfos,t),s=A(t),o=t.fields.some((({type:t})=>O.has(t))),n=s||o,{allowedWorkflows:l}=this,d=l.includes("create")||l.includes("create-features"),p=l.includes("update"),c=t=>!i||!1!==i.enabled&&!1!==i[t],u=d&&!!r?.supportsAdd&&c("addEnabled"),h=p&&!!r?.supportsUpdate&&c("updateEnabled"),w=!n&&p&&!!r?.supportsDelete&&c("deleteEnabled"),f=[];e||(u&&f.push("create"),h&&f.push("update"),w&&f.push("delete"));const m=h&&!n&&(!i||!1!==i.attributeUpdatesEnabled),y=h&&!n&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),k=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:f,attributeUpdatesEnabled:m,geometryUpdatesEnabled:y,hasAttachments:k,attachmentsOnCreateEnabled:k&&d&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:!n&&k&&(!i||!1!==i.attachmentsOnUpdateEnabled),hasInvalidFormTemplate:s,hasUnsupportedFields:o}}};t([f()],x.prototype,"_editableItems",void 0),t([f({readOnly:!0})],x.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],x.prototype,"_activityQueue",void 0),t([f({value:[...P]})],x.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],x.prototype,"canCreate",null),t([f({readOnly:!0})],x.prototype,"canUpdate",null),t([f()],x.prototype,"editableItems",null),t([f({readOnly:!0})],x.prototype,"failures",void 0),t([f()],x.prototype,"attachmentsViewModel",void 0),t([f()],x.prototype,"featureFormViewModel",void 0),t([f()],x.prototype,"featureTemplatesViewModel",void 0),t([f()],x.prototype,"labelOptions",null),t([f()],x.prototype,"layerInfos",null),t([f()],x.prototype,"sketchViewModel",void 0),t([f()],x.prototype,"snappingOptions",null),t([f()],x.prototype,"spinnerViewModel",void 0),t([f()],x.prototype,"state",null),t([f({readOnly:!0})],x.prototype,"syncing",null),t([f()],x.prototype,"updating",null),t([f()],x.prototype,"tooltipOptions",null),t([f()],x.prototype,"view",null),t([f()],x.prototype,"pageStack",void 0),t([f()],x.prototype,"showDiscardEditsPrompt",void 0),t([f()],x.prototype,"_candidateCommitted",void 0),t([f()],x.prototype,"page",null),t([f()],x.prototype,"selectedTemplateItem",null),t([f()],x.prototype,"featureFormDisabled",null),t([f()],x.prototype,"canGoBack",null),t([f()],x.prototype,"shouldShowDeleteButton",null),t([f()],x.prototype,"hasPendingEdits",null),t([f()],x.prototype,"useDeprecatedCreateWorkflow",void 0),x=t([m(S)],x);const B=x;export{B as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import o from"../../core/Evented.js";import{HandleOwnerMixin as s}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{isEditableLayer as k}from"../../layers/support/editableLayers.js";import{getOwningPortalUrl as g,getEffectiveLayerCapabilities as v,isFeatureLayer as W}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import _ from"../Attachments/AttachmentsViewModel.js";import F from"./CreateFeaturesWorkflow.js";import C from"./CreateWorkflow.js";import{workflowDeprecation as E}from"./deprecationUtils.js";import I from"./UpdateWorkflow.js";import{whenEditorLayerView as U}from"./workflowUtils.js";import{formTemplateHasInvalidFields as A,unsupportedDateFieldTypes as O}from"../FeatureForm/featureFormUtils.js";import V from"../FeatureForm/FeatureFormViewModel.js";import j from"../FeatureTemplates/FeatureTemplatesViewModel.js";import M from"../Sketch/SketchViewModel.js";import T from"../Spinner/SpinnerViewModel.js";const S="esri.widgets.Editor.EditorViewModel",L=n.getLogger(S),P=["create","create-features","update"];function D(t,e,a){L.error(new i(t,e,a))}function G(t,e){return t?t.find((t=>t.layer===e)):void 0}let x=class extends(s(o.EventedAccessor)){constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new _({capabilities:{editing:!0}}),this.featureFormViewModel=new V,this.featureTemplatesViewModel=new j,this.sketchViewModel=new M({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new T,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow())},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0||await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),c((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const o={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(o);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(o):this.startCreateFeaturesWorkflowAtFeatureCreation(o)})),c((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...P]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,o=!(i&&"visible"in i)||!!i.visible;return e.visible&&o&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(L,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1==!!t.activeEditableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditableItem?.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(E(L,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(E(L,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(E(L,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():D("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasInvalidFormTemplate??!1)}itemHasUnsupportedFields(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasUnsupportedFields??!1)}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map,i=r?.editableLayers.toArray()??[],o=r?.allTables.toArray().filter(W)??[];await Promise.all(o.map((t=>t.load())));const s=o.filter((t=>k(t))),n=[...i.reverse(),...s.reverse()];if(!e||!i)return;const l=[],p=[];for(const a of n){const r=e.find((t=>t.layer===a)),i=r?l:p;if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)i.push(this._makeEditableItemForLayer(a.sublayers.at(t),!!r?.suspended))}else i.push(this._makeEditableItemForLayer(a,!!r?.suspended))}if(t.aborted)return;const c=this._editableItems;this._editableItems=new a(l.concat(p)),c.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&D("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return F.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return C.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return I.create(this,t,((t,e)=>this._applyEdits(t,e)))}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await g(t.url):null,o={returnServiceEditsOption:(!i||!b(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const a=await U(this.view,t).catch((()=>null));return r=await t.applyEdits(e,o),a&&await h((()=>!a.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{D("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=v(t),r=a?.operations,i=G(this.layerInfos,t),o=A(t),s=t.fields.some((({type:t})=>O.has(t))),n=o||s,{allowedWorkflows:l}=this,d=l.includes("create")||l.includes("create-features"),p=l.includes("update"),c=t=>!i||!1!==i.enabled&&!1!==i[t],u=d&&!!r?.supportsAdd&&c("addEnabled"),h=p&&!!r?.supportsUpdate&&c("updateEnabled"),w=!n&&p&&!!r?.supportsDelete&&c("deleteEnabled"),f=[];e||(u&&f.push("create"),h&&f.push("update"),w&&f.push("delete"));const m=h&&!n&&(!i||!1!==i.attributeUpdatesEnabled),y=h&&!n&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),k=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:f,attributeUpdatesEnabled:m,geometryUpdatesEnabled:y,hasAttachments:k,attachmentsOnCreateEnabled:k&&d&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:!n&&k&&(!i||!1!==i.attachmentsOnUpdateEnabled),hasInvalidFormTemplate:o,hasUnsupportedFields:s}}};t([f()],x.prototype,"_editableItems",void 0),t([f({readOnly:!0})],x.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],x.prototype,"_activityQueue",void 0),t([f({value:[...P]})],x.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],x.prototype,"canCreate",null),t([f({readOnly:!0})],x.prototype,"canUpdate",null),t([f()],x.prototype,"editableItems",null),t([f({readOnly:!0})],x.prototype,"failures",void 0),t([f()],x.prototype,"attachmentsViewModel",void 0),t([f()],x.prototype,"featureFormViewModel",void 0),t([f()],x.prototype,"featureTemplatesViewModel",void 0),t([f()],x.prototype,"labelOptions",null),t([f()],x.prototype,"layerInfos",null),t([f()],x.prototype,"sketchViewModel",void 0),t([f()],x.prototype,"snappingOptions",null),t([f()],x.prototype,"spinnerViewModel",void 0),t([f()],x.prototype,"state",null),t([f({readOnly:!0})],x.prototype,"syncing",null),t([f()],x.prototype,"updating",null),t([f()],x.prototype,"tooltipOptions",null),t([f()],x.prototype,"view",null),t([f()],x.prototype,"pageStack",void 0),t([f()],x.prototype,"showDiscardEditsPrompt",void 0),t([f()],x.prototype,"_candidateCommitted",void 0),t([f()],x.prototype,"page",null),t([f()],x.prototype,"selectedTemplateItem",null),t([f()],x.prototype,"featureFormDisabled",null),t([f()],x.prototype,"canGoBack",null),t([f()],x.prototype,"shouldShowDeleteButton",null),t([f()],x.prototype,"hasPendingEdits",null),t([f()],x.prototype,"useDeprecatedCreateWorkflow",void 0),x=t([m(S)],x);const B=x;export{B as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import{makeHandle as a}from"../../core/handleUtils.js";import{abortMaybe as i}from"../../core/maybe.js";import{onAbort as o,createAbortError as r,throwIfAborted as s,debounce as n}from"../../core/promiseUtils.js";import l from"../../core/Queue.js";import{whenOnce as d,watch as c}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{isNonSpatialTable as u}from"../../layers/support/layerUtils.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import{UpdateFeatureWorkflow as f}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as m}from"./UpdateRecordWorkflow.js";import g from"./UpdateWorkflowData.js";import k from"./Workflow.js";import{createWorkflowSteps as y,fetchCandidates as v}from"./workflowUtils.js";var W;const _="candidate-highlight",b="esri.widgets.Editor.UpdateWorkflow";let S=W=class extends k{constructor(t){super(t),this._workflowStack=new l((t=>{let e;for(e of t);return e})),this.type="update"}initialize(){const{featureFormViewModel:t}=this.data.viewModel,e=t.relatedRecordCallbacks;t.relatedRecordCallbacks={addRelatedRecord:()=>{},editRelatedRecord:({relatedFeature:t})=>this.startUpdating(t)},this.addHandles(a((()=>t.relatedRecordCallbacks=e)))}get activeEditableItem(){const{activeWorkflow:t}=this;return U(t)?t.data.editableItem:void 0}get activeWorkflow(){return this._workflowStack.last()}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditableItem?.attachmentsOnUpdateEnabled}get shouldAllowAttachmentEditing(){return!!this.activeEditableItem?.supports.includes("update")}get hasPendingEdits(){return Array.from(this._workflowStack).some((t=>t.hasPendingEdits))}get helpMessage(){return"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditableItem?.hasInvalidFormTemplate}get hasUnsupportedFields(){return!!this.activeEditableItem?.hasUnsupportedFields}get updating(){return this.updatingHandles.updating}async back(t){this.activeWorkflow?(this.activeWorkflow.hasPendingEdits&&await(t?.()),await this.cancelActiveWorkflow({force:!0})):this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancelActiveWorkflow(t){await(this.activeWorkflow?.cancel(t)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((t=>t.commit())),await super.commit()}static create(t,e,a){const i=new W({data:new g({applyEditsCallback:a,viewModel:t}),onCommit:async()=>{}});return i._set("steps",this._createWorkflowSteps(i,e)),i}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startUpdating(t){try{const e=await this._createNestedWorkflow(t);await this._pushWorkflow(e)}catch(a){throw new e("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}}async deleteActiveFeature(){const{activeWorkflow:t}=this;if(!t)throw new e("editor:nothing-to-delete","There is no feature to delete");U(t)?await t.deleteAndCommit():await t.cancel()}async cancelAll(){await this._drainWorkflowStack((t=>t.cancel({force:!0})))}async _createNestedWorkflow(t){const e=u(t.sourceLayer)?m:f,{applyEditsCallback:a,viewModel:i}=this.data,o=await e.create({feature:t,viewModel:i,applyEdits:a});return await d((()=>!o.updating)),o}async _drainWorkflowStack(t){const e=this._workflowStack,a=[];for(;e.length>0;){const i=e.pop(),o=t(i).then((()=>i.destroy()));this.updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_highlight(t){const e=this.data.viewModel.view;if(!e||!t)return;const a=t&&e.allLayerViews.items.find((({layer:e})=>e===t.layer||"subtype-sublayer"===t.layer?.type&&t.layer?.parent===e));h(a)&&this.handles.add(a.highlight(t),_)}async _popWorkflow(){this._workflowStack.pop()?.destroy();const t=await this._reconcileWorkflowStack();if(t.failureCount>0)throw new e("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",t)}async _pushWorkflow(t){const a="update-feature"===t.type||"create-features"===t.type;this.activeWorkflow?.exit({removeSketchHandles:a}),await t.start(),this._workflowStack.push(t);const i=await this._reconcileWorkflowStack();if(i.failureCount>0)throw new e("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",i)}async _reconcileWorkflowStack(){const t=this._workflowStack;try{const e=t.peek();return await(e?.enter()),{activeWorkflow:e,failureCount:0}}catch(e){t.pop().destroy();const{activeWorkflow:a,failureCount:i}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:i+1}}}_unhighlight(){this.handles.remove(_)}static _createWorkflowSteps(t,l="awaiting-feature-to-update"){const{data:p,handles:w}=t;return y(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],l,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e}=p.viewModel,n=p.viewModel.view;let l=null;w.add(a((()=>{l=i(l)})),this.id),p.rootFeature=null,p.candidates=[];const d=n.on("immediate-click",(async a=>{e.location=a.mapPoint,e.visible=!0,l?.abort();const{editableItems:i}=p.viewModel;l=new AbortController;const d=await new Promise(((t,e)=>{o(l?.signal,(()=>e(r()))),t(v(i,n,a,l?.signal))}));s(l),p.candidates=d.reduce(((t,e)=>e.error?t:[...t,...e.value]),[]),e.visible=1===p.candidates.length,0!==p.candidates.length&&(1===p.candidates.length?(p.rootFeature=p.candidates[0],t.go("editing-existing-feature").catch((()=>{})).then((()=>e.visible=!1))):t.next())}));n.focus(),w.add(d,this.id)},async tearDown(){w.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){p.rootFeature=null,w.add(c((()=>p.rootFeature),(e=>{t._unhighlight(),t._highlight(e)})),this.id)},async tearDown(){t._unhighlight(),w.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:a,viewModel:i}=t.data;if(!a)throw new e("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await t.startUpdating(a),i.spinnerViewModel.visible=!1;const o=n((async()=>{await d((()=>!t.updating)),t.previous()}));t.addHandles(c((()=>t.nestedWorkflowCount),((t,e)=>{0===t&&0!==e&&o()})))},async tearDown(){await t.cancelAll()}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){p.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){p.viewModel.attachmentsViewModel.mode="view"}})})}};t([p()],S.prototype,"activeEditableItem",null),t([p()],S.prototype,"activeWorkflow",null),t([p()],S.prototype,"nestedWorkflowCount",null),t([p()],S.prototype,"shouldShowAttachments",null),t([p()],S.prototype,"shouldAllowAttachmentEditing",null),t([p()],S.prototype,"hasPendingEdits",null),t([p()],S.prototype,"helpMessage",null),t([p()],S.prototype,"reliesOnOwnerAdminPrivileges",null),t([p()],S.prototype,"hasInvalidFormTemplate",null),t([p()],S.prototype,"hasUnsupportedFields",null),t([p()],S.prototype,"updating",null),S=W=t([w(b)],S);const U=t=>!!t&&/update-/.test(t.type),C=S;export{C as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import{makeHandle as a}from"../../core/handleUtils.js";import{abortMaybe as i}from"../../core/maybe.js";import{onAbort as o,createAbortError as r,throwIfAborted as s,debounce as n}from"../../core/promiseUtils.js";import l from"../../core/Queue.js";import{whenOnce as d,watch as c}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{isNonSpatialTable as u}from"../../layers/support/layerUtils.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import{UpdateFeatureWorkflow as f}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as m}from"./UpdateRecordWorkflow.js";import g from"./UpdateWorkflowData.js";import k from"./Workflow.js";import{createWorkflowSteps as v,fetchCandidates as y}from"./workflowUtils.js";var W;const _="candidate-highlight",b="esri.widgets.Editor.UpdateWorkflow";let S=W=class extends k{constructor(t){super(t),this._workflowStack=new l((t=>{let e;for(e of t);return e})),this.type="update"}initialize(){const{featureFormViewModel:t}=this.data.viewModel,e=t.relatedRecordCallbacks;t.relatedRecordCallbacks={addRelatedRecord:()=>{},editRelatedRecord:({relatedFeature:t})=>this.startUpdating(t)},this.addHandles(a((()=>t.relatedRecordCallbacks=e)))}get activeEditableItem(){const{activeWorkflow:t}=this;return U(t)?t.data.editableItem:void 0}get activeWorkflow(){return this._workflowStack.last()}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditableItem?.attachmentsOnUpdateEnabled}get shouldAllowAttachmentEditing(){return!!this.activeEditableItem?.supports.includes("update")}get hasPendingEdits(){return Array.from(this._workflowStack).some((t=>t.hasPendingEdits))}get helpMessage(){return"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditableItem?.hasInvalidFormTemplate}get hasUnsupportedFields(){return!!this.activeEditableItem?.hasUnsupportedFields}get updating(){return this.updatingHandles.updating}async back(t=(()=>Promise.resolve(!0))){if(this.activeWorkflow){if(this.activeWorkflow.hasPendingEdits){if(!await t())return}this.activeWorkflow.hasPreviousStep?await this.activeWorkflow.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancelActiveWorkflow(t){await(this.activeWorkflow?.cancel(t)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((t=>t.commit())),await super.commit()}static create(t,e,a){const i=new W({data:new g({applyEditsCallback:a,viewModel:t}),onCommit:async()=>{}});return i._set("steps",this._createWorkflowSteps(i,e)),i}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startUpdating(t){try{const e=await this._createNestedWorkflow(t);await this._pushWorkflow(e)}catch(a){throw new e("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}}async deleteActiveFeature(){const{activeWorkflow:t}=this;if(!t)throw new e("editor:nothing-to-delete","There is no feature to delete");U(t)?await t.deleteAndCommit():await t.cancel(),1===this.nestedWorkflowCount?this.emit("complete"):await this._popWorkflow()}async cancelAll(){await this._drainWorkflowStack((t=>t.cancel({force:!0})))}async _createNestedWorkflow(t){const e=u(t.sourceLayer)?m:f,{applyEditsCallback:a,viewModel:i}=this.data,o=await e.create({feature:t,viewModel:i,applyEdits:a});return await d((()=>!o.updating)),o}async _drainWorkflowStack(t){const e=this._workflowStack,a=[];for(;e.length>0;){const i=e.pop(),o=t(i).then((()=>i.destroy()));this.updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_highlight(t){const e=this.data.viewModel.view;if(!e||!t)return;const a=t&&e.allLayerViews.items.find((({layer:e})=>e===t.layer||"subtype-sublayer"===t.layer?.type&&t.layer?.parent===e));h(a)&&this.handles.add(a.highlight(t),_)}async _popWorkflow(){this._workflowStack.pop()?.destroy();const t=await this._reconcileWorkflowStack();if(t.failureCount>0)throw new e("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",t)}async _pushWorkflow(t){const a="update-feature"===t.type||"create-features"===t.type;this.activeWorkflow?.exit({removeSketchHandles:a}),await t.start(),this._workflowStack.push(t);const i=await this._reconcileWorkflowStack();if(i.failureCount>0)throw new e("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",i)}async _reconcileWorkflowStack(){const t=this._workflowStack;try{const e=t.peek();return await(e?.enter()),{activeWorkflow:e,failureCount:0}}catch(e){t.pop().destroy();const{activeWorkflow:a,failureCount:i}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:i+1}}}_unhighlight(){this.handles.remove(_)}static _createWorkflowSteps(t,l="awaiting-feature-to-update"){const{data:p,handles:w}=t;return v(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],l,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e}=p.viewModel,n=p.viewModel.view;let l=null;w.add(a((()=>{l=i(l)})),this.id),p.rootFeature=null,p.candidates=[];const d=n.on("immediate-click",(async a=>{e.location=a.mapPoint,e.visible=!0,l?.abort();const{editableItems:i}=p.viewModel;l=new AbortController;const d=await new Promise(((t,e)=>{o(l?.signal,(()=>e(r()))),t(y(i,n,a,l?.signal))}));s(l),p.candidates=d.reduce(((t,e)=>e.error?t:[...t,...e.value]),[]),e.visible=1===p.candidates.length,0!==p.candidates.length&&(1===p.candidates.length?(p.rootFeature=p.candidates[0],t.go("editing-existing-feature").catch((()=>{})).then((()=>e.visible=!1))):t.next())}));n.focus(),w.add(d,this.id)},async tearDown(){w.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){p.rootFeature=null,w.add(c((()=>p.rootFeature),(e=>{t._unhighlight(),t._highlight(e)})),this.id)},async tearDown(){t._unhighlight(),w.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:a,viewModel:i}=t.data;if(!a)throw new e("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await t.startUpdating(a),i.spinnerViewModel.visible=!1;const o=n((async()=>{await d((()=>!t.updating)),t.previous()}));t.addHandles(c((()=>t.nestedWorkflowCount),((t,e)=>{0===t&&0!==e&&o()})))},async tearDown(){await t.cancelAll()}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){p.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){p.viewModel.attachmentsViewModel.mode="view"}})})}};t([p()],S.prototype,"activeEditableItem",null),t([p()],S.prototype,"activeWorkflow",null),t([p()],S.prototype,"nestedWorkflowCount",null),t([p()],S.prototype,"shouldShowAttachments",null),t([p()],S.prototype,"shouldAllowAttachmentEditing",null),t([p()],S.prototype,"hasPendingEdits",null),t([p()],S.prototype,"helpMessage",null),t([p()],S.prototype,"reliesOnOwnerAdminPrivileges",null),t([p()],S.prototype,"hasInvalidFormTemplate",null),t([p()],S.prototype,"hasUnsupportedFields",null),t([p()],S.prototype,"updating",null),S=W=t([w(b)],S);const U=t=>!!t&&/update-/.test(t.type),C=S;export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import{abortMaybe as r}from"../../core/maybe.js";import{throwIfNotAbortError as i}from"../../core/promiseUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";let p=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._setupAbortController=null,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter((t=>!t.parent)).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get hasUnsupportedFields(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}async back(t){this.hasPendingEdits&&await(t?.()),this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancel(t={force:!0}){return!1!==t.force?this._cancel(t):new Promise(((s,o)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel({...t,force:!0}).then(s)},deny:()=>o(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})}))}async commit(){this.handles.remove(this._handleKeys.beforeCommit),await(this.onCommit?.(this.data)),this.handles.remove(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex((e=>e.id===t));this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({notify:!1}),await this.start()}async save(){await this.commit(),await this.reset()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}async _cancel({notify:t=!0,error:e}={}){this.started&&(this._set("started",!1),await this.steps[this._stepIndex].tearDown({canceled:!0})),this.handles.remove([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}async _go(t=-1,e=!1){const{steps:s}=this;if(t<=-1||t>=s.length)return;if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&(this._setupAbortController=r(this._setupAbortController),await s[this._lastStepIndex].tearDown({canceled:e})),this._setupAbortController=new AbortController;const o=this._setupAbortController.signal;try{await s[t].setUp(o)}catch(n){i(n)}this._setupAbortController.signal===o&&(this._setupAbortController=null),o.aborted||(this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps())}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([n()],p.prototype,"data",void 0),t([n()],p.prototype,"hasNextStep",null),t([n()],p.prototype,"hasPreviousStep",null),t([n()],p.prototype,"onCommit",void 0),t([n()],p.prototype,"reliesOnOwnerAdminPrivileges",null),t([n()],p.prototype,"hasInvalidFormTemplate",null),t([n()],p.prototype,"hasUnsupportedFields",null),t([n()],p.prototype,"shouldShowAttachments",null),t([n()],p.prototype,"shouldAllowAttachmentEditing",null),t([n()],p.prototype,"started",void 0),t([n({readOnly:!0})],p.prototype,"stepId",null),t([n()],p.prototype,"steps",void 0),t([n({readOnly:!0})],p.prototype,"type",void 0),t([n()],p.prototype,"helpMessage",null),t([n()],p.prototype,"hasPendingEdits",null),t([n()],p.prototype,"keyboardCancellationEnabled",null),p=t([a("esri.widgets.Editor.Workflow")],p);const h=p;export{h as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import{abortMaybe as r}from"../../core/maybe.js";import{throwIfNotAbortError as i}from"../../core/promiseUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";let p=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._setupAbortController=null,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter((t=>!t.parent)).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get hasUnsupportedFields(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}async back(t=(()=>Promise.resolve(!0))){if(this.hasPendingEdits){if(!await t())return}this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancel(t={force:!0}){return!1!==t.force?this._cancel(t):new Promise(((s,o)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel({...t,force:!0}).then(s)},deny:()=>o(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})}))}async commit(){this.handles.remove(this._handleKeys.beforeCommit),await(this.onCommit?.(this.data)),this.handles.remove(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex((e=>e.id===t));this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({notify:!1}),await this.start()}async save(){await this.commit(),await this.reset()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}async _cancel({notify:t=!0,error:e}={}){this.started&&(this._set("started",!1),await this.steps[this._stepIndex].tearDown({canceled:!0})),this.handles.remove([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}async _go(t=-1,e=!1){const{steps:s}=this;if(t<=-1||t>=s.length)return;if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&(this._setupAbortController=r(this._setupAbortController),await s[this._lastStepIndex].tearDown({canceled:e})),this._setupAbortController=new AbortController;const o=this._setupAbortController.signal;try{await s[t].setUp(o)}catch(n){i(n)}this._setupAbortController.signal===o&&(this._setupAbortController=null),o.aborted||(this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps())}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([n()],p.prototype,"data",void 0),t([n()],p.prototype,"hasNextStep",null),t([n()],p.prototype,"hasPreviousStep",null),t([n()],p.prototype,"onCommit",void 0),t([n()],p.prototype,"reliesOnOwnerAdminPrivileges",null),t([n()],p.prototype,"hasInvalidFormTemplate",null),t([n()],p.prototype,"hasUnsupportedFields",null),t([n()],p.prototype,"shouldShowAttachments",null),t([n()],p.prototype,"shouldAllowAttachmentEditing",null),t([n()],p.prototype,"started",void 0),t([n({readOnly:!0})],p.prototype,"stepId",null),t([n()],p.prototype,"steps",void 0),t([n({readOnly:!0})],p.prototype,"type",void 0),t([n()],p.prototype,"helpMessage",null),t([n()],p.prototype,"hasPendingEdits",null),t([n()],p.prototype,"keyboardCancellationEnabled",null),p=t([a("esri.widgets.Editor.Workflow")],p);const h=p;export{h as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Graphic.js";import{createTask as t}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as r,makeHandle as n}from"../../core/handleUtils.js";import{clone as i}from"../../core/lang.js";import{throwIfAborted as a,whenOrAbort as s,eachAlways as l}from"../../core/promiseUtils.js";import{watch as o,whenOnce as c}from"../../core/reactiveUtils.js";import{px2pt as u}from"../../core/screenUtils.js";import{diff as p}from"../../core/accessorSupport/diffUtils.js";import{getDisplayFieldName as y}from"../../layers/support/fieldUtils.js";import{calculateTolerance as f}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as d}from"../../renderers/support/lengthUtils.js";import{getTransformationType as m,TransformationType as g}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as h,getSize as b}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as w,i3sPatchingEnabled as v}from"../../support/featureFlags.js";import{to3D as S}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as j}from"../../symbols/support/symbolUtils.js";import{GraphicState as I}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as U}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as V,filterGraphicHits as F}from"../../views/support/hitTestSelectUtils.js";function T(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!O(t.renderer))return{rotation:null,size:null};let r=null,n=null;const i=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=h(t,e)));1===i.length&&(r=z(i[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&m(t)===g.RealWorldSize&&null!=b(t,e)));return 1===a.length&&(n=E(a[0],t)),{rotation:r,size:n}}function z(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=e.field,i=t.fields&&t.fields.filter((e=>e.name===n)),a=i&&1===i.length?i[0].type:"double",s={initial:0,current:0};return{field:n,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,A((s.current+360)%360,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function x(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function L(e,t,r){if(null==t)return 0;const{symbol:n}=S(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const i=n.symbolLayers.at(0);if(!i)return 0;switch(i.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return i.size||Math.min($.icon,(await e(i,$.icon))[0])||$.icon}case"text":return i.size||$.text;case"line":return i.size||$.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return x(await t(i,e.scale/$.viewScaleSizeFactor),r)}case"path":return(null!=i.width?i.width:i.height)||e.scale/$.viewScaleSizeFactor;case"extrude":return i.size||e.scale/$.viewScaleSizeFactor;default:return 0}}function E(e,t){const r=e.field,n=e.axis,i=t.fields&&t.fields.filter((e=>e.name===r)),a=i&&1===i.length?i[0].type:"double",s={updating:!1,initial:0,current:0},l=d[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:r,fieldType:a,getDefault:async(e,t)=>A(o(await L(t,e,n)),a),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,A(s.current,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:ne(e.valueUnit),axis:e.axis}}function A(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function O(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function M(e,t){const r=await j(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t});null!=p(e.symbol,r)&&(e.symbol=r)}function R(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function k(e,t,i,a){await G(e,t,a);const s=e.on("create",(async r=>{if("cancel"===r.state)return G(e,t,a);if("complete"===r.state){const e=r.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await M(e,a),i(e)}}));return r([s,n((()=>e.cancel()))])}async function G(e,t,r){const n=t.layer,i={...t.template.prototype.attributes};await P(e,n,i,r),e.layer.elevationInfo=n.elevationInfo,await e.create(R(n.geometryType),{graphicProperties:{attributes:i,sourceLayer:n},hasZ:n.capabilities.data.supportsZ,geometryToPlace:t.geometryToPlace??void 0})}async function P(t,r,n,i){const a=new e({sourceLayer:r,attributes:n}),{rotation:s,size:l}=T(a);let o=await j(a,{useSourceLayer:!0,webStyleCache:i}),c=!1;for(const e of[l,s]){if(null==e)continue;null==n[e.field]&&(n[e.field]=await e.getDefault(o,t.view),c=!0)}switch(c&&(o=await j(a,{useSourceLayer:!0,webStyleCache:i})),o?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=o;break;case"simple-line":case"line-3d":t.polylineSymbol=o;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=o}D(t.tooltipOptions,l,s)}function D(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function C(e,t){return e?e.find((e=>e.layer===t)):void 0}async function q(e,t,r,n){if(0===e.length)return[];const{updatable:i,graphicsByLayer:a}=await r.async((async()=>{const{results:i}=await s(V(t,r),n),a=new Map,l=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};F(i).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&a.has(t)));return 0!==o.length&&r.stopPropagation(),{updatable:o,graphicsByLayer:a}}));return s(l(i.map((async({layer:e})=>{const{objectIdField:t}=e,r="displayField"in e?e.displayField:null,i=[t];null!=r&&e.fieldsIndex.has(r)&&i.push(r);const s=a.get(e);if(!!s.some((e=>i.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=i,t.returnGeometry=!1,t.objectIds=s.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:n}).then((({features:e})=>e))}return s}))),n)}async function Z(e,t,r,n){if(0===e.length)return[];let i=null;const a=await r.async((async()=>{const{results:a}=await s(t.hitTest(r),n);if(0===a.length)return[];const l=new Set;i=F(a),i.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:r})=>l.has(e)&&(t.includes("update")||t.includes("delete")||r)));return o.length>0&&r.stopPropagation(),o}));return s(l(a.map((({layer:e})=>{const a=e.objectIdField,s="displayField"in e?e.displayField:null,l=y({displayField:s,fields:e.fields}),o=[a];null!=l&&e.fieldsIndex.has(l)&&o.push(l);const c=e.createQuery();c.outFields=o,c.returnGeometry=!1;const u="renderer"in e?f({renderer:e.renderer,event:r}):0;return c.geometry=U(r.mapPoint,u,t),c.outSpatialReference=t.spatialReference,e.queryFeatures(c,{signal:n}).then((({features:t})=>(i?.forEach((({graphic:r})=>{r.layer!==e||t.some((e=>e.getObjectId()===r.getObjectId()))||t.push(r)})),t)))}))),n)}async function Q(e,t,r,n){switch(t.type){case"3d":return q(e,t,r,n);case"2d":return Z(e,t,r,n)}}async function B(e,t,r){const{sourceLayer:n}=e,i=n.createQuery();i.objectIds=[e.getAttribute(n.objectIdField)],i.outFields=["*"],i.outSpatialReference=t,i.returnM=n.capabilities.data.supportsM,i.returnZ=n.capabilities.data.supportsZ,w()&&v()&&"scene"===n.type&&null!=n.infoFor3D&&(i.returnGeometry=!0,i.formatOf3DObjects="3D_glb");const s=await n.queryFeatures(i,{signal:r});a(r);return s.features[0]}async function W(e,t,r,n,i){let a=!1;const{rotation:s,size:l}=n;[s,l].forEach((async r=>{if(null==r)return;const n=t.getAttribute(r.field);if(null!=n)r.initValue(n);else{const n=await r.getDefault(t.symbol,e.view);r.initValue(n),t.setAttribute(r.field,n),a=!0}})),a&&await M(t,i);const o={multipleSelectionEnabled:!1};return"point"===r.geometryType&&(o.enableRotation=null!=s,o.enableScaling=null!=l),D(e.tooltipOptions,l,s),e.layer.elevationInfo=r.elevationInfo,e.update(t,o)}function _(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function H(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function J(e,t,r,n,i){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=n.rotation,s=_(r.toolEventInfo);if(null!=a&&null!=s)if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.initValue();else{a.isUpdatingInteractively=!0;const{field:r,getValue:n}=a;t.setAttribute(r,n(s.angle,e))}const l=n.size,o=H(r.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:r,getValue:n}=l;t.setAttribute(r,n(o.xScale,e))}await M(t,i)}async function K(e,t,i,a,s,l){const c=pe(e);await M(c,l),a.map.add(i.layer),i.layer.add(c);const u=e.sourceLayer,p=le(a,u);await Y(a,c),await W(i,c,u,t,l);const y=N(i,e,c);let f=null;p.then((e=>f=e)).catch((()=>{}));const d=t.size,m=t.rotation,g=o((()=>e.attributes),(async e=>{let t=!1;for(const r in e){const n=e[r];n!==c.getAttribute(r)&&(c.setAttribute(r,n),null==d||d.isUpdatingInteractively||d.field!==r||d.initValue(n),null==m||m.isUpdatingInteractively||m.field!==r||m.initValue(n),(null==f||f.requiredFields.includes(r))&&(t=!0))}t&&await M(c,l)})),h=i.on("update",(async e=>{const r=e.graphics[0];if("complete"===e.state)return W(i,r,u,t,l);await J(a,r,e,t,l),s(pe(r),e)})),b=i.on(["undo","redo"],(async e=>{s(pe(e.graphics[0]),e)}));return{interactive:r([b,h,n((()=>i.cancel())),g]),visual:y}}function N(e,i,s){const l=e.view,o=i.sourceLayer,u=i.layer,p=i.getAttribute(u.objectIdField);let y=null;function f(e){y?.abort(),y=t((async t=>{const r=await le(l,o);a(t),r.setVisibility?.(p,e)}))}return f(!1),r([X(l,s,(e=>f(!e))),n((async()=>{f(!0);const t=await le(l,o);await c((()=>!t.updating)),e.layer.remove(s)}))])}function X(e,t,n){if("3d"===e.type){const i=new I({graphic:t});return r([e.trackGraphicState(i),o((()=>i.displaying),n)])}return o((()=>t.visible),n)}async function Y(e,t){if("3d"===e.type){const r=new I({graphic:t}),n=e.trackGraphicState(r);await c((()=>r.displaying)),n.remove()}else await c((()=>t.visible))}const $={icon:u(24),text:u(12),line:u(1),viewScaleSizeFactor:100};function ee(e,t,r){let n=!1;return e.filter((e=>!!n||(n=e===t,n))).map((e=>r[e]()))}function te(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function re(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const r=te(e.viewModel.featureTemplatesViewModel.items);null==r||r.supportsUpload||(e.creationInfo=r,t.shift())}return t}function ne(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function ie(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ae(e){const{creationInfo:t,viewModel:r}=e;if(!t)return!1;const{layer:n}=t,i=r.editableItems.find((e=>e.layer===n));if(i)return i.attachmentsOnCreateEnabled;const a=n.capabilities?.data,s=r.layerInfos?.find((e=>e.layer===n));return!(!(a&&"supportsAttachment"in a&&a.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const se=e=>/-stop/.test(e)||/vertex-/.test(e),le=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function oe(e){return"createInteractiveEditSession"in e}const ce=Symbol();function ue(e){return e&&"object"==typeof e&&ce in e}function pe(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=i(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function ye(e){const t=e.cursor;return e.cursor="progress",n((()=>e.cursor=t))}export{ce as UsesSketchViewModelSymbol,re as avoidFeatureTemplateSelectionWithOnlyOneItem,oe as canCreateInteractiveEditSession,pe as cloneGraphicExceptMesh,ee as createWorkflowSteps,Q as fetchCandidates,B as fetchFullFeature,C as findLayerInfo,T as getVisualVariableAttributes,se as isTerminalUpdateEventType,ie as prepareAttachmentsForCreateWorkflow,k as setUpFeatureAdd,K as setUpGeometryUpdate,ae as shouldShowAttachmentsForCreateWorkflow,ye as showProgressCursor,$ as sizeDefaults,ne as sizeVariableUnitToLengthUnit,G as startCreatingNewFeature,W as startUpdatingFeature,M as updateGraphicSymbolWhenRequired,J as visualVariableInteractiveUpdate,le as whenEditorLayerView,Y as whenGraphicDisplayed,ue as workflowUsesSketchViewModel};
5
+ import e from"../../Graphic.js";import{createTask as t}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as i,makeHandle as r}from"../../core/handleUtils.js";import{clone as n}from"../../core/lang.js";import{throwIfAborted as a,whenOrAbort as s,eachAlways as l}from"../../core/promiseUtils.js";import{watch as o,whenOnce as c}from"../../core/reactiveUtils.js";import{px2pt as u}from"../../core/screenUtils.js";import{diff as p}from"../../core/accessorSupport/diffUtils.js";import{getDisplayFieldName as y}from"../../layers/support/fieldUtils.js";import{calculateTolerance as d}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as f}from"../../renderers/support/lengthUtils.js";import{getTransformationType as m,TransformationType as h}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as g,getSize as b}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as w,i3sPatchingEnabled as v}from"../../support/featureFlags.js";import{to3D as S}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as j}from"../../symbols/support/symbolUtils.js";import{GraphicState as I}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as U}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as V,filterGraphicHits as F}from"../../views/support/hitTestSelectUtils.js";function T(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!A(t.renderer))return{rotation:null,size:null};let i=null,r=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=g(t,e)));1===n.length&&(i=z(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&m(t)===h.RealWorldSize&&null!=b(t,e)));return 1===a.length&&(r=E(a[0],t)),{rotation:i,size:r}}function z(e,t){const i="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,r=e.field,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",s={initial:0,current:0};return{field:r,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-i*e,O((s.current+360)%360,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function x(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function L(e,t,i){if(null==t)return 0;const{symbol:r}=S(t);if(null==r||"web-style"===r.type||"cim"===r.type)return 0;const n=r.symbolLayers.at(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min($.icon,(await e(n,$.icon))[0])||$.icon}case"text":return n.size||$.text;case"line":return n.size||$.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return x(await t(n,e.scale/$.viewScaleSizeFactor),i)}case"path":return(null!=n.width?n.width:n.height)||e.scale/$.viewScaleSizeFactor;case"extrude":return n.size||e.scale/$.viewScaleSizeFactor;default:return 0}}function E(e,t){const i=e.field,r=e.axis,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",s={updating:!1,initial:0,current:0},l=f[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:i,fieldType:a,getDefault:async(e,t)=>O(o(await L(t,e,r)),a),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,O(s.current,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:re(e.valueUnit),axis:e.axis}}function O(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 A(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 k(e,t){const i=await j(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t});null!=p(e.symbol,i)&&(e.symbol=i)}function G(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function M(e,t,n,a){await R(e,t,a);const s=e.on("create",(async i=>{if("cancel"===i.state)return R(e,t,a);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await k(e,a),n(e)}}));return i([s,r((()=>e.cancel()))])}async function R(e,t,i){const r=t.layer,n={...t.template.prototype.attributes};await C(e,r,n,i),e.layer.elevationInfo=r.elevationInfo,await e.create(G(r.geometryType),{graphicProperties:{attributes:n,sourceLayer:r},hasZ:r.capabilities.data.supportsZ,geometryToPlace:t.geometryToPlace??void 0})}async function C(t,i,r,n){const a=new e({sourceLayer:i,attributes:r}),{rotation:s,size:l}=T(a);let o=await j(a,{useSourceLayer:!0,webStyleCache:n}),c=!1;for(const e of[l,s]){if(null==e)continue;null==r[e.field]&&(r[e.field]=await e.getDefault(o,t.view),c=!0)}switch(c&&(o=await j(a,{useSourceLayer:!0,webStyleCache:n})),o?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=o;break;case"simple-line":case"line-3d":t.polylineSymbol=o;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=o}P(t.tooltipOptions,l,s)}function P(e,t,i){e.visualVariables=null!=t||null!=i?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=i?{valueType:i.fieldType,rotationType:i.rotationType??"geographic"}:null}:null}function D(e,t){return e?e.find((e=>e.layer===t)):void 0}async function q(e,t,i,r){if(0===e.length)return[];const{updatable:n,graphicsByLayer:a}=await i.async((async()=>{const{results:n}=await s(V(t,i),r),a=new Map,l=e=>{const t=e.layer,i=a.get(t);if(!i){const e=new Array;return a.set(t,e),e}return i};F(n).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&a.has(t)));return 0!==o.length&&i.stopPropagation(),{updatable:o,graphicsByLayer:a}}));return s(l(n.map((async({layer:e})=>{const{objectIdField:t}=e,i="displayField"in e?e.displayField:null,n=[t];null!=i&&e.fieldsIndex.has(i)&&n.push(i);const s=a.get(e);if(!!s.some((e=>n.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=n,t.returnGeometry=!1,t.objectIds=s.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:r}).then((({features:e})=>e))}return s}))),r)}async function Z(e,t,i,r){if(0===e.length)return[];let n=null;const a=await i.async((async()=>{const{results:a}=await s(t.hitTest(i),r);if(0===a.length)return[];const l=new Set;n=F(a),n.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:i})=>l.has(e)&&(t.includes("update")||t.includes("delete")||i)));return o.length>0&&i.stopPropagation(),o}));return s(l(a.map((({layer:e})=>{const a=e.objectIdField,s="displayField"in e?e.displayField:null,l=y({displayField:s,fields:e.fields}),o=[a];null!=l&&e.fieldsIndex.has(l)&&o.push(l);const c=e.createQuery();c.outFields=o,c.returnGeometry=!1;const u="renderer"in e?d({renderer:e.renderer,event:i}):0;return c.geometry=U(i.mapPoint,u,t),c.outSpatialReference=t.spatialReference,e.queryFeatures(c,{signal:r}).then((({features:t})=>(n?.forEach((({graphic:i})=>{i.layer!==e||t.some((e=>e.getObjectId()===i.getObjectId()))||t.push(i)})),t)))}))),r)}async function Q(e,t,i,r){switch(t.type){case"3d":return q(e,t,i,r);case"2d":return Z(e,t,i,r)}}async function B(e,t,i){const{sourceLayer:r}=e,n=r.createQuery();n.objectIds=[e.getAttribute(r.objectIdField)],n.outFields=["*"],n.outSpatialReference=t,n.returnM=r.capabilities.data.supportsM,n.returnZ=r.capabilities.data.supportsZ,w()&&v()&&"scene"===r.type&&null!=r.infoFor3D&&(n.returnGeometry=!0,n.formatOf3DObjects="3D_glb");const s=await r.queryFeatures(n,{signal:i});a(i);return s.features[0]}async function W(e,t,i,r,n){let a=!1;const{rotation:s,size:l}=r;[s,l].forEach((async i=>{if(null==i)return;const r=t.getAttribute(i.field);if(null!=r)i.initValue(r);else{const r=await i.getDefault(t.symbol,e.view);i.initValue(r),t.setAttribute(i.field,r),a=!0}})),a&&await k(t,n);const o={multipleSelectionEnabled:!1};return"point"===i.geometryType&&(o.enableRotation=null!=s,o.enableScaling=null!=l),P(e.tooltipOptions,l,s),e.layer.elevationInfo=i.elevationInfo,e.update(t,o)}function _(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function H(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function J(e,t,i,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=r.rotation,s=_(i.toolEventInfo);if(null!=a&&null!=s)if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.initValue();else{a.isUpdatingInteractively=!0;const{field:i,getValue:r}=a;t.setAttribute(i,r(s.angle,e))}const l=r.size,o=H(i.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:i,getValue:r}=l;t.setAttribute(i,r(o.xScale,e))}await k(t,n)}async function K(e,t,n,a,s,l){const c=pe(e);await k(c,l),a.map.add(n.layer),n.layer.add(c);const u=e.sourceLayer,p=le(a,u);await Y(a,c),await W(n,c,u,t,l);const y=N(n,e,c);let d=null;p.then((e=>d=e)).catch((()=>{}));const f=t.size,m=t.rotation,h=o((()=>e.attributes),(async e=>{let t=!1;for(const i in e){const r=e[i];r!==c.getAttribute(i)&&(c.setAttribute(i,r),null==f||f.isUpdatingInteractively||f.field!==i||f.initValue(r),null==m||m.isUpdatingInteractively||m.field!==i||m.initValue(r),(null==d||d.requiredFields.includes(i))&&(t=!0))}t&&await k(c,l)})),g=n.on("update",(async e=>{const i=e.graphics[0];if("complete"===e.state)return W(n,i,u,t,l);await J(a,i,e,t,l),s(pe(i),e)})),b=n.on(["undo","redo"],(async e=>{s(pe(e.graphics[0]),e)})),w=n.updateOnGraphicClick;return{visual:i([y,r((()=>{n.updateOnGraphicClick=!1}))]),interactive:i([b,g,r((()=>n.cancel())),h,r((()=>{n.updateOnGraphicClick=w}))])}}function N(e,n,s){const l=e.view,o=n.sourceLayer,u=n.layer,p=n.getAttribute(u.objectIdField);let y=null;function d(e){y?.abort(),y=t((async t=>{const i=await le(l,o);a(t),i.setVisibility?.(p,e)}))}return d(!1),i([X(l,s,(e=>d(!e))),r((async()=>{d(!0);const t=await le(l,o);await c((()=>!t.updating)),e.layer.remove(s)}))])}function X(e,t,r){if("3d"===e.type){const n=new I({graphic:t});return i([e.trackGraphicState(n),o((()=>n.displaying),r)])}return o((()=>t.visible),r)}async function Y(e,t){if("3d"===e.type){const i=new I({graphic:t}),r=e.trackGraphicState(i);await c((()=>i.displaying)),r.remove()}else await c((()=>t.visible))}const $={icon:u(24),text:u(12),line:u(1),viewScaleSizeFactor:100};function ee(e,t,i){let r=!1;return e.filter((e=>!!r||(r=e===t,r))).map((e=>i[e]()))}function te(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function ie(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const i=te(e.viewModel.featureTemplatesViewModel.items);null==i||i.supportsUpload||(e.creationInfo=i,t.shift())}return t}function re(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function ne(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ae(e){const{creationInfo:t,viewModel:i}=e;if(!t)return!1;const{layer:r}=t,n=i.editableItems.find((e=>e.layer===r));if(n)return n.attachmentsOnCreateEnabled;const a=r.capabilities?.data,s=i.layerInfos?.find((e=>e.layer===r));return!(!(a&&"supportsAttachment"in a&&a.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const se=e=>/-stop/.test(e)||/vertex-/.test(e),le=(e,t)=>{const i="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(i)};function oe(e){return"createInteractiveEditSession"in e}const ce=Symbol();function ue(e){return e&&"object"==typeof e&&ce in e}function pe(e){const t=e.geometry;if("mesh"===t?.type){const i=e.cloneShallow();return i.attributes=n(e.attributes),i.geometry=t.cloneShallow(),i.geometry.transform=t.transform?.clone()??null,i}return e.clone()}function ye(e){const t=e.cursor;return e.cursor="progress",r((()=>e.cursor=t))}export{ce as UsesSketchViewModelSymbol,ie as avoidFeatureTemplateSelectionWithOnlyOneItem,oe as canCreateInteractiveEditSession,pe as cloneGraphicExceptMesh,ee as createWorkflowSteps,Q as fetchCandidates,B as fetchFullFeature,D as findLayerInfo,T as getVisualVariableAttributes,se as isTerminalUpdateEventType,ne as prepareAttachmentsForCreateWorkflow,M as setUpFeatureAdd,K as setUpGeometryUpdate,ae as shouldShowAttachmentsForCreateWorkflow,ye as showProgressCursor,$ as sizeDefaults,re as sizeVariableUnitToLengthUnit,R as startCreatingNewFeature,W as startUpdatingFeature,k as updateGraphicSymbolWhenRequired,J as visualVariableInteractiveUpdate,le as whenEditorLayerView,Y as whenGraphicDisplayed,ue as workflowUsesSketchViewModel};
package/widgets/Editor.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import o from"../core/Logger.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as i,on as a,when as r,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as v}from"./Editor/deprecationUtils.js";import w from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import{renderItem as k,ItemList as b}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as T}from"./support/decorators/accessibleHandler.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{SketchTooltipControls as I}from"./support/SketchTooltipControls/SketchTooltipControls.js";import{substitute as S}from"../intl/substitute.js";const P="esri-editor",U=`${P}__panel`,j=`${P}__prompt`,D={base:`${P} esri-widget esri-widget--panel`,actions:`${P}__actions`,helpMessage:`${P}__help-message`,panelToolbar:`${U}-toolbar`,panelContent:`${U}-content`,panelContentMessage:`${U}-content__message`,panelContentSection:`${U}-content__section`,panelContentSectionGroup:`${U}-content__section__group`,panelContentScrimContainer:`${U}-content__scrim-container`,settingsContainer:`${P}__settings`,featureTemplatesContainer:`${P}__feature-templates-container`,notice:`${P}__notice`,templateItemContentEnd:`${P}__template-item-content-end`,templateItemContentEndSuccess:`${P}__template-item-content-end--success`,templateItemContentEndError:`${P}__template-item-content-end--error`,templateItemLoader:`${P}__template-item-loader`,promptContainer:j,promptHeader:`${j}__header`,promptHeading:`${j}__header__heading`,promptMessage:`${j}__message`,promptDivider:`${j}__divider`,promptActions:`${j}__actions`,widgetIcon:"esri-icon-edit"},$={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},sketchTooltipControls:!0};function B(e){requestAnimationFrame((()=>e.setFocus()))}const O="exclamation-mark-triangle",x="esri.widgets.Editor",H=o.getLogger(x);let N=class extends(s(f)){constructor(e,t){super(e,t),this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>this._renderTemplateContentEnd(e),renderItemDescription:e=>this._renderTemplateDescription(e),renderItemLabel:e=>this._renderTemplateLabel(e),renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this.headingLevel=4,this.iconClass=D.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new w,this.visibleElements={...$},this._renderSelectIcon=()=>L("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({handleBack:e,heading:t,headingLevel:s,key:o},...n)=>{const{messagesCommon:i,viewModel:a,visibleElements:r}=this,l=a.sketchViewModel,c=a.syncing||this._attachments.submitting;return L("calcite-flow-item",{closable:!1,heading:t,headingLevel:s,key:o,loading:c,onCalciteFlowItemBack:e??void 0},L("div",{key:"panel-toolbar",class:D.panelToolbar},this._renderSettings(),r.undoRedoButtons&&[L("calcite-button",{key:"undo-button",label:i.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},i.undo),L("calcite-button",{key:"redo-button",label:i.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},i.redo)]),...n)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;if("create-features"===t?.type&&y(t.data.creationInfo))return this._showPrompt({title:e.cancelUploadTitle,message:e.cancelUploadWarningMessage,yesLabel:e.discardUpload,noLabel:e.continueUpload});const s="create"===t?.type;return this._showPrompt({title:e[s?"cancelAddTitle":"cancelEditTitle"],message:e[s?"cancelAddWarningMessage":"cancelEditWarningMessage"],yesLabel:e[s?"discardFeature":"discardEdits"],noLabel:e[s?"continueAdding":"continueEditing"]})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.previous(),this._clearPrompt())},this._onAttachmentsError=e=>{this._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null},this._onBack=this._onBack.bind(this),this._onSave=this._onSave.bind(this),this._onDelete=this._onDelete.bind(this),this._onToggleUpdateWorkflow=this._onToggleUpdateWorkflow.bind(this),this._onAttachmentAdd=this._onAttachmentAdd.bind(this),this._onAttachmentUpdate=this._onAttachmentUpdate.bind(this),this._onAttachmentDelete=this._onAttachmentDelete.bind(this)}initialize(){this.addHandles([i((()=>M(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),i((()=>this.viewModel.selectedTemplateItem),(e=>this._featureTemplates.select(e,{emit:!1}))),a((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),i((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),i((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),l),r((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch)}),l),r((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),r((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:n}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{n(),this._clearPrompt()}}}}})),i((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),i((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return C({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js")})}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger",type:"primary"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get useDeprecatedCreateWorkflow(){return this.viewModel.useDeprecatedCreateWorkflow}set useDeprecatedCreateWorkflow(e){this.viewModel.useDeprecatedCreateWorkflow=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...$,...e,snappingControlsElements:{...$.snappingControlsElements,...e?.snappingControlsElements}}}startCreateWorkflowAtFeatureTypeSelection(){return v(H,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return v(H,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return v(H,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this;if(!e)return L("div",{key:"empty",class:D.base});const{state:t}=e;return L("div",{key:"base",class:D.base},L("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e,t))),this._renderPage(e.page,t)),this._renderPrompt())}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return L("div",null)}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:o,_onBack:n}=this;return L(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:n,heading:o.selectTemplate,headingLevel:s},L("div",{key:"feature-templates",class:D.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:o,messagesCommon:n,headingLevel:i,_onBack:a,viewModel:r}=this;if(!t)return null;const l=t.type,c=r.featureFormViewModel,d="update"===l&&!t.hasPendingEdits||r.syncing||c.updating,p="update"===l?o.editFeature:o.createFeatures,m="update"===l?n.update:n.create,h="create-features"===l&&"create-new"===t.createFeatureState,u="create-features"===l?t.numPendingFeatures:0,g=u>1?S(o.createFeaturesTemplate,{numFeatures:u}):m,_=t.shouldShowAttachments,f=c.inputs.every((e=>!e.visible))&&!_?this._renderMessage(S(o.clickToFinishTemplate,{button:m})):L("div",{key:"panel-content-section",class:D.panelContentSection},this._renderNotices(t),L("div",{class:D.panelContentSectionGroup},this._featureForm.render(),_&&L("div",{key:"attachments"},L(F,{level:M(i)},o.attachments),this._attachments.render())));return L(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:p,headingLevel:i,handleBack:a},L("div",{key:"panel-content",class:this.classes(D.panelContent,{[D.panelContentScrimContainer]:h})},f,h&&L("calcite-scrim",null)),this._renderFooterActions([{clickHandler:this._onSave,disabled:d,label:g,type:"primary"},r.shouldShowDeleteButton?{...this._deleteButtonCommonInfo,clickHandler:this._onDelete,disabled:r.syncing,label:n.delete}:null]))}_renderNotices(e){return[this._renderOwnerAdminNotice(e),this._renderInvalidFormTemplateNotice(e),this._renderInvalidDateFieldNotice(e)]}_renderOwnerAdminNotice(e){return e?.reliesOnOwnerAdminPrivileges&&this._renderNotice(this.messages.ownerAdminNotice)}_renderInvalidFormTemplateNotice(e){return e?.hasInvalidFormTemplate&&this._renderNotice(this.messages.formFieldUpdateError,{icon:O})}_renderInvalidDateFieldNotice(e){return e?.hasUnsupportedFields&&this._renderNotice(this.messages.formFieldUnsupportedUpdateError,{icon:O})}_renderNotice(e,t){return L("calcite-notice",{open:!0,scale:"s",class:D.notice,...t},L("div",{slot:"message"},e))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this;let o=null;return e.group.items.some((e=>(s.itemHasUnsupportedFields(e)?o=t.formFieldUnsupportedCreateError:s.itemHasInvalidFormTemplate(e)&&(o=t.formFieldCreateError),o))),o?this._renderNotice(o,{icon:O}):null}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_onBack:o,headingLevel:n,messages:i,messagesCommon:a}=this;return L(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:i.addAttachment,headingLevel:n,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),this._renderFooterActions([{label:t.submitting?a.cancel:a.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentAdd}]))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_onBack:o,activeWorkflow:n,headingLevel:i,messages:a,messagesCommon:r}=this;return n?L(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:a.editAttachment,headingLevel:i,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),n.shouldAllowAttachmentEditing?this._renderFooterActions([{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,clickHandler:this._onAttachmentDelete,disabled:t.submitting,label:r.delete}]):void 0):null}_renderMessage(e){return L("div",{key:"panel-content-message",class:D.panelContentMessage},e)}_renderFooterActions(e){return L("div",{key:"footer-actions",slot:"footer",class:D.actions},e.filter(t).map((({type:e,disabled:t,class:s,clickHandler:o,label:n,...i},a)=>L("calcite-button",{key:`action-${a}`,slot:"footer-actions",class:s,disabled:t??!1,onclick:o,width:"full",...i},n))))}_renderPrompt(){const e=this._prompt;if(!e)return null;const{title:t,message:s,context:o,actions:n}=e,i=n.secondary;let a;switch(o){case"danger":a="danger";break;case"info":a="brand";break;default:a="neutral"}const r=L("calcite-button",{afterCreate:B,appearance:"solid",key:"prompt-primary-button",kind:a,onclick:n.primary.action,scale:"m",width:i?"half":"full"},n.primary.label),l=i&&L("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:a,onclick:i.action,scale:"m",width:"half"},i.label);return L("calcite-scrim",{key:"prompt"},L("div",{class:`${D.promptContainer}--${o}`},L("div",{class:D.promptHeader},L("calcite-icon",{icon:O}),L(F,{class:D.promptHeading,level:this.headingLevel},t)),L("div",{class:D.promptMessage},s),L("div",{class:D.promptDivider}),L("div",{class:D.promptActions},l,r)))}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:o,viewModel:n}=this,{canUpdate:i}=n,a=this._featureTemplates.viewModel.numberOfFeatureTemplates,r=!i&&0===a;return L(t,{active:this._isPanelActive(e),key:"landing-panel",heading:o.widgetLabel,headingLevel:s},L("div",{key:"landing-content",class:D.panelContent},i&&L("div",{key:"edit-actions",class:D.panelContentSection},this._renderUpdateActions(e)),a>0&&L("div",{key:"create-actions",class:D.panelContentSection},this._renderCreateActions()),r&&L("div",{key:"no-content",class:D.panelContentMessage},o.noEditableLayers)),this._renderFooterHelpMessages())}_renderFooterHelpMessages(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage,n=o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:null;return n?L("div",{key:"footer-actions",slot:"footer",class:D.helpMessage},n):null}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this,o={id:"select",label:s.select};return L("div",{key:"update-actions"},L(F,{level:M(this.headingLevel)},t.editFeatures),L("calcite-list",{selectionMode:"single",selectionAppearance:"border"},k({grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===e?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return L("div",{key:"create-actions"},L(F,{level:M(t)},s.createFeatures),L("div",{key:"templates",class:D.featureTemplatesContainer},e.render()))}_renderTemplateLabel(e){return e.label}_renderTemplateDescription(e){const t=this._getUploadForTemplateItem(e);if(!t)return null;const{messages:s}=this;switch(t.state){case"pending":return s?.uploadPending;case"error":return s?.uploadError;default:return null}}_renderTemplateContentEnd(e){const t=this._getUploadForTemplateItem(e),s=L("calcite-icon",{key:"upload-icon",class:D.templateItemContentEnd,icon:"upload-to"});if(!t)return e.supportsUpload?s:null;switch(t.state){case"success":return L("calcite-icon",{key:"success-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndSuccess),icon:"check"});case"error":return L("calcite-icon",{key:"error-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndError),icon:"exclamation-mark-circle-f"});case"pending":return L("calcite-loader",{class:D.templateItemLoader,inline:!0,key:"loader",label:"",scale:"s",type:"indeterminate"});case"canceled":case"default":return s}}_getUploadForTemplateItem(e){const t=this.activeWorkflow;if("create-features"!==t?.type)return null;const{data:s}=t,{creationInfo:o,upload:n}=s;return o?.template===e.template&&o?.layer===e.layer?n:null}_renderFeatureList(e){const{EditorPanel:s,_onBack:o,headingLevel:n,messages:i,messagesTemplates:a,viewModel:{activeWorkflow:r,editableItems:l}}=this;if("update"!==r?.type)return null;const c=r.data.candidates,d=S(i.multipleFeaturesTemplate,{total:c.length}),p=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,o=this._filterText.toLowerCase(),{title:n}=s.layer,i=l.find((e=>e.layer===s.layer));if(!i)return null;const{attachmentsOnUpdateEnabled:a,supports:r}=i;return(r.includes("update")||r.includes("delete")||a)&&(!o||t?.toLowerCase().includes(o)||n?.toLowerCase().includes(o))})).filter(t).forEach((e=>{m++;const t=e.data.layer;p.has(t)?p.get(t)?.items.push(e):p.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=l.toArray().map((({layer:e})=>p.get(e))).filter(t),u=m>10||this._filterText.length>0;return L(s,{active:this._isPanelActive(e),key:"feature-list",heading:d,headingLevel:n,handleBack:o},L("div",{key:"feature-list",class:D.panelContent},L("div",{class:D.panelContentSection},b({enableListScroll:!1,filterEnabled:u,filterText:this._filterText,id:this.id,items:h,messages:{filterPlaceholder:a.filterPlaceholder,noItems:a.noItems,noMatches:a.noMatches},onFilterChange:e=>this._filterText=e,onItemMouseEnter:e=>this.viewModel.selectFeature(e.data),onItemMouseLeave:()=>this.viewModel.selectFeature(null),onItemSelect:e=>this.viewModel.selectFeature(e.data,!0)}))))}_isPanelActive(e){return this.viewModel.state===e}_renderSettings(){const e=this.visibleElements,t=e.snappingControls,s=e.sketchTooltipControls;return t||s?L("calcite-accordion",{key:"settings",class:D.settingsContainer,appearance:"transparent"},L("calcite-accordion-item",{heading:this.messagesCommon?.settings,iconStart:"gear"},s&&L(I,{tooltipOptions:this.tooltipOptions}),t&&L(A,{snappingOptions:this.snappingOptions,view:this.view,visibleElements:e.snappingControlsElements,afterCreate:e=>e.layerListOpen=!1}))):null}_getLabel(e){const t=e.layer;if(!t)return null;const s=t.fieldsIndex.get(t.objectIdField),o=s.alias||s.name,{attributes:n}=e,i=m(t);return i&&n[i]&&`${n[i]}`||`${o}: ${n[s.name]}`}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const i=n(),{view:a}=this,r=a?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>i.resolve(!0)},secondary:{label:o,action:()=>i.resolve(!1)}}},i.promise.finally((()=>{this._clearPrompt(),r&&a?.focus()}))}_onSave(){this.viewModel.saveWorkflow()}_onDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}}}async _onBack(e){return e?.stopPropagation(),this.viewModel.back()}_onAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.previous()):this._attachments.addAttachment().then((()=>e.previous())))}_onAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.previous()):this._attachments.updateAttachment().then((()=>e.previous())))}_onAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}}};e([c()],N.prototype,"_featureForm",void 0),e([c()],N.prototype,"_attachments",void 0),e([c()],N.prototype,"_featureTemplates",void 0),e([c()],N.prototype,"_filterText",void 0),e([c()],N.prototype,"_prompt",void 0),e([c()],N.prototype,"_spinner",void 0),e([c()],N.prototype,"_deleteButtonCommonInfo",null),e([c({readOnly:!0})],N.prototype,"activeWorkflow",null),e([c()],N.prototype,"allowedWorkflows",null),e([c()],N.prototype,"useDeprecatedCreateWorkflow",null),e([c()],N.prototype,"headingLevel",void 0),e([c()],N.prototype,"iconClass",void 0),e([c()],N.prototype,"label",null),e([c()],N.prototype,"labelOptions",null),e([c()],N.prototype,"layerInfos",null),e([c(),E("esri/widgets/Editor/t9n/Editor")],N.prototype,"messages",void 0),e([c(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),e([c(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],N.prototype,"messagesTemplates",void 0),e([c()],N.prototype,"snappingOptions",null),e([c()],N.prototype,"tooltipOptions",null),e([c()],N.prototype,"supportingWidgetDefaults",void 0),e([c()],N.prototype,"view",null),e([c(),W(["workflow-cancel","workflow-commit"])],N.prototype,"viewModel",void 0),e([c()],N.prototype,"visibleElements",void 0),e([d("visibleElements")],N.prototype,"castVisibleElements",null),e([T()],N.prototype,"_onSave",null),e([T()],N.prototype,"_onDelete",null),e([T()],N.prototype,"_onBack",null),e([T()],N.prototype,"_onAttachmentAdd",null),e([T()],N.prototype,"_onAttachmentUpdate",null),e([T()],N.prototype,"_onAttachmentDelete",null),N=e([p(x)],N);const V=N;export{V as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import o from"../core/Logger.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as a,on as i,when as r,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as w}from"./Editor/deprecationUtils.js";import v from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import{renderItem as k,ItemList as b}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as T}from"./support/decorators/accessibleHandler.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{SketchTooltipControls as I}from"./support/SketchTooltipControls/SketchTooltipControls.js";import{substitute as S}from"../intl/substitute.js";const P="esri-editor",U=`${P}__panel`,j=`${P}__prompt`,D={base:`${P} esri-widget esri-widget--panel`,actions:`${P}__actions`,helpMessage:`${P}__help-message`,panelToolbar:`${U}-toolbar`,panelContent:`${U}-content`,panelContentMessage:`${U}-content__message`,panelContentSection:`${U}-content__section`,panelContentSectionGroup:`${U}-content__section__group`,panelContentScrimContainer:`${U}-content__scrim-container`,settingsContainer:`${P}__settings`,featureTemplatesContainer:`${P}__feature-templates-container`,notice:`${P}__notice`,templateItemContentEnd:`${P}__template-item-content-end`,templateItemContentEndSuccess:`${P}__template-item-content-end--success`,templateItemContentEndError:`${P}__template-item-content-end--error`,templateItemLoader:`${P}__template-item-loader`,promptContainer:j,promptHeader:`${j}__header`,promptHeading:`${j}__header__heading`,promptMessage:`${j}__message`,promptDivider:`${j}__divider`,promptActions:`${j}__actions`,widgetIcon:"esri-icon-edit"},$={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},sketchTooltipControls:!0};function B(e){requestAnimationFrame((()=>e.setFocus()))}const O="exclamation-mark-triangle",x="esri.widgets.Editor",H=o.getLogger(x);let N=class extends(s(f)){constructor(e,t){super(e,t),this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>this._renderTemplateContentEnd(e),renderItemDescription:e=>this._renderTemplateDescription(e),renderItemLabel:e=>this._renderTemplateLabel(e),renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this.headingLevel=4,this.iconClass=D.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements={...$},this._renderSelectIcon=()=>L("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({handleBack:e,heading:t,headingLevel:s,key:o},...n)=>{const{messagesCommon:a,viewModel:i,visibleElements:r}=this,l=i.sketchViewModel,c=i.syncing||this._attachments.submitting;return L("calcite-flow-item",{closable:!1,heading:t,headingLevel:s,key:o,loading:c,onCalciteFlowItemBack:e??void 0},L("div",{key:"panel-toolbar",class:D.panelToolbar},this._renderSettings(),r.undoRedoButtons&&[L("calcite-button",{key:"undo-button",label:a.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},a.undo),L("calcite-button",{key:"redo-button",label:a.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},a.redo)]),...n)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;if("create-features"===t?.type&&y(t.data.creationInfo))return this._showPrompt({title:e.cancelUploadTitle,message:e.cancelUploadWarningMessage,yesLabel:e.discardUpload,noLabel:e.continueUpload});const s="create"===t?.type;return this._showPrompt({title:e[s?"cancelAddTitle":"cancelEditTitle"],message:e[s?"cancelAddWarningMessage":"cancelEditWarningMessage"],yesLabel:e[s?"discardFeature":"discardEdits"],noLabel:e[s?"continueAdding":"continueEditing"]})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null},this._onBack=this._onBack.bind(this),this._onSave=this._onSave.bind(this),this._onDelete=this._onDelete.bind(this),this._onToggleUpdateWorkflow=this._onToggleUpdateWorkflow.bind(this),this._onAttachmentAdd=this._onAttachmentAdd.bind(this),this._onAttachmentUpdate=this._onAttachmentUpdate.bind(this),this._onAttachmentDelete=this._onAttachmentDelete.bind(this)}initialize(){this.addHandles([a((()=>M(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),a((()=>this.viewModel.selectedTemplateItem),(e=>this._featureTemplates.select(e,{emit:!1}))),i((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),a((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),l),r((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch)}),l),r((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),r((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:n}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{n(),this._clearPrompt()}}}}})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return C({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js")})}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger",type:"primary"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get useDeprecatedCreateWorkflow(){return this.viewModel.useDeprecatedCreateWorkflow}set useDeprecatedCreateWorkflow(e){this.viewModel.useDeprecatedCreateWorkflow=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...$,...e,snappingControlsElements:{...$.snappingControlsElements,...e?.snappingControlsElements}}}startCreateWorkflowAtFeatureTypeSelection(){return w(H,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return w(H,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return w(H,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this;if(!e)return L("div",{key:"empty",class:D.base});const{state:t}=e;return L("div",{key:"base",class:D.base},L("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e,t))),this._renderPage(e.page,t)),this._renderPrompt())}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return L("div",null)}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:o,_onBack:n}=this;return L(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:n,heading:o.selectTemplate,headingLevel:s},L("div",{key:"feature-templates",class:D.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:o,messagesCommon:n,headingLevel:a,_onBack:i,viewModel:r}=this;if(!t)return null;const l=t.type,c=r.featureFormViewModel,d="update"===l&&!t.hasPendingEdits||r.syncing||c.updating,p="update"===l?o.editFeature:o.createFeatures,m="update"===l?n.update:n.create,h="create-features"===l&&"create-new"===t.createFeatureState,u="create-features"===l?t.numPendingFeatures:0,g=u>1?S(o.createFeaturesTemplate,{numFeatures:u}):m,_=t.shouldShowAttachments,f=c.inputs.every((e=>!e.visible))&&!_?this._renderMessage(S(o.clickToFinishTemplate,{button:m})):L("div",{key:"panel-content-section",class:D.panelContentSection},this._renderNotices(t),L("div",{class:D.panelContentSectionGroup},this._featureForm.render(),_&&L("div",{key:"attachments"},L(F,{level:M(a)},o.attachments),this._attachments.render())));return L(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:p,headingLevel:a,handleBack:i},L("div",{key:"panel-content",class:this.classes(D.panelContent,{[D.panelContentScrimContainer]:h})},f,h&&L("calcite-scrim",null)),this._renderFooterActions([{clickHandler:this._onSave,disabled:d,label:g,type:"primary"},r.shouldShowDeleteButton?{...this._deleteButtonCommonInfo,clickHandler:this._onDelete,disabled:r.syncing,label:n.delete}:null]))}_renderNotices(e){return[this._renderOwnerAdminNotice(e),this._renderInvalidFormTemplateNotice(e),this._renderInvalidDateFieldNotice(e)]}_renderOwnerAdminNotice(e){return e?.reliesOnOwnerAdminPrivileges&&this._renderNotice(this.messages.ownerAdminNotice)}_renderInvalidFormTemplateNotice(e){return e?.hasInvalidFormTemplate&&this._renderNotice(this.messages.formFieldUpdateError,{icon:O})}_renderInvalidDateFieldNotice(e){return e?.hasUnsupportedFields&&this._renderNotice(this.messages.formFieldUnsupportedUpdateError,{icon:O})}_renderNotice(e,t){return L("calcite-notice",{open:!0,scale:"s",class:D.notice,...t},L("div",{slot:"message"},e))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this;let o=null;return e.group.items.some((e=>(s.itemHasUnsupportedFields(e)?o=t.formFieldUnsupportedCreateError:s.itemHasInvalidFormTemplate(e)&&(o=t.formFieldCreateError),o))),o?this._renderNotice(o,{icon:O}):null}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_onBack:o,headingLevel:n,messages:a,messagesCommon:i}=this;return L(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:a.addAttachment,headingLevel:n,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),this._renderFooterActions([{label:t.submitting?i.cancel:i.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentAdd}]))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_onBack:o,activeWorkflow:n,headingLevel:a,messages:i,messagesCommon:r}=this;return n?L(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:i.editAttachment,headingLevel:a,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),n.shouldAllowAttachmentEditing?this._renderFooterActions([{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,clickHandler:this._onAttachmentDelete,disabled:t.submitting,label:r.delete}]):void 0):null}_renderMessage(e){return L("div",{key:"panel-content-message",class:D.panelContentMessage},e)}_renderFooterActions(e){return L("div",{key:"footer-actions",slot:"footer",class:D.actions},e.filter(t).map((({type:e,disabled:t,class:s,clickHandler:o,label:n,...a},i)=>L("calcite-button",{key:`action-${i}`,slot:"footer-actions",class:s,disabled:t??!1,onclick:o,width:"full",...a},n))))}_renderPrompt(){const e=this._prompt;if(!e)return null;const{title:t,message:s,context:o,actions:n}=e,a=n.secondary;let i;switch(o){case"danger":i="danger";break;case"info":i="brand";break;default:i="neutral"}const r=L("calcite-button",{afterCreate:B,appearance:"solid",key:"prompt-primary-button",kind:i,onclick:n.primary.action,scale:"m",width:a?"half":"full"},n.primary.label),l=a&&L("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:i,onclick:a.action,scale:"m",width:"half"},a.label);return L("calcite-scrim",{key:"prompt"},L("div",{class:`${D.promptContainer}--${o}`},L("div",{class:D.promptHeader},L("calcite-icon",{icon:O}),L(F,{class:D.promptHeading,level:this.headingLevel},t)),L("div",{class:D.promptMessage},s),L("div",{class:D.promptDivider}),L("div",{class:D.promptActions},l,r)))}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:o,viewModel:n}=this,{canUpdate:a}=n,i=this._featureTemplates.viewModel.numberOfFeatureTemplates,r=!a&&0===i;return L(t,{active:this._isPanelActive(e),key:"landing-panel",heading:o.widgetLabel,headingLevel:s},L("div",{key:"landing-content",class:D.panelContent},a&&L("div",{key:"edit-actions",class:D.panelContentSection},this._renderUpdateActions(e)),i>0&&L("div",{key:"create-actions",class:D.panelContentSection},this._renderCreateActions()),r&&L("div",{key:"no-content",class:D.panelContentMessage},o.noEditableLayers)),this._renderFooterHelpMessages())}_renderFooterHelpMessages(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage,n=o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:null;return n?L("div",{key:"footer-actions",slot:"footer",class:D.helpMessage},n):null}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this,o={id:"select",label:s.select};return L("div",{key:"update-actions"},L(F,{level:M(this.headingLevel)},t.editFeatures),L("calcite-list",{selectionMode:"single",selectionAppearance:"border"},k({grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===e?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return L("div",{key:"create-actions"},L(F,{level:M(t)},s.createFeatures),L("div",{key:"templates",class:D.featureTemplatesContainer},e.render()))}_renderTemplateLabel(e){return e.label}_renderTemplateDescription(e){const t=this._getUploadForTemplateItem(e);if(!t)return null;const{messages:s}=this;switch(t.state){case"pending":return s?.uploadPending;case"error":return s?.uploadError;default:return null}}_renderTemplateContentEnd(e){const t=this._getUploadForTemplateItem(e),s=L("calcite-icon",{key:"upload-icon",class:D.templateItemContentEnd,icon:"upload-to"});if(!t)return e.supportsUpload?s:null;switch(t.state){case"success":return L("calcite-icon",{key:"success-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndSuccess),icon:"check"});case"error":return L("calcite-icon",{key:"error-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndError),icon:"exclamation-mark-circle-f"});case"pending":return L("calcite-loader",{class:D.templateItemLoader,inline:!0,key:"loader",label:"",scale:"s",type:"indeterminate"});case"canceled":case"default":return s}}_getUploadForTemplateItem(e){const t=this.activeWorkflow;if("create-features"!==t?.type)return null;const{data:s}=t,{creationInfo:o,upload:n}=s;return o?.template===e.template&&o?.layer===e.layer?n:null}_renderFeatureList(e){const{EditorPanel:s,_onBack:o,headingLevel:n,messages:a,messagesTemplates:i,viewModel:{activeWorkflow:r,editableItems:l}}=this;if("update"!==r?.type)return null;const c=r.data.candidates,d=S(a.multipleFeaturesTemplate,{total:c.length}),p=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,o=this._filterText.toLowerCase(),{title:n}=s.layer,a=l.find((e=>e.layer===s.layer));if(!a)return null;const{attachmentsOnUpdateEnabled:i,supports:r}=a;return(r.includes("update")||r.includes("delete")||i)&&(!o||t?.toLowerCase().includes(o)||n?.toLowerCase().includes(o))})).filter(t).forEach((e=>{m++;const t=e.data.layer;p.has(t)?p.get(t)?.items.push(e):p.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=l.toArray().map((({layer:e})=>p.get(e))).filter(t),u=m>10||this._filterText.length>0;return L(s,{active:this._isPanelActive(e),key:"feature-list",heading:d,headingLevel:n,handleBack:o},L("div",{key:"feature-list",class:D.panelContent},L("div",{class:D.panelContentSection},b({enableListScroll:!1,filterEnabled:u,filterText:this._filterText,id:this.id,items:h,messages:{filterPlaceholder:i.filterPlaceholder,noItems:i.noItems,noMatches:i.noMatches},onFilterChange:e=>this._filterText=e,onItemMouseEnter:e=>this.viewModel.selectFeature(e.data),onItemMouseLeave:()=>this.viewModel.selectFeature(null),onItemSelect:e=>this.viewModel.selectFeature(e.data,!0)}))))}_isPanelActive(e){return this.viewModel.state===e}_renderSettings(){const e=this.visibleElements,t=e.snappingControls,s=e.sketchTooltipControls;return t||s?L("calcite-accordion",{key:"settings",class:D.settingsContainer,appearance:"transparent"},L("calcite-accordion-item",{heading:this.messagesCommon?.settings,iconStart:"gear"},s&&L(I,{tooltipOptions:this.tooltipOptions}),t&&L(A,{snappingOptions:this.snappingOptions,view:this.view,visibleElements:e.snappingControlsElements,afterCreate:e=>e.layerListOpen=!1}))):null}_getLabel(e){const t=e.layer;if(!t)return null;const s=t.fieldsIndex.get(t.objectIdField),o=s.alias||s.name,{attributes:n}=e,a=m(t);return a&&n[a]&&`${n[a]}`||`${o}: ${n[s.name]}`}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const a=n(),{view:i}=this,r=i?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}},a.promise.finally((()=>{this._clearPrompt(),r&&i?.focus()}))}_onSave(){this.viewModel.saveWorkflow()}_onDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}}}async _onBack(e){return e?.stopPropagation(),this.viewModel.back()}_onAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))}_onAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))}_onAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}}};e([c()],N.prototype,"_featureForm",void 0),e([c()],N.prototype,"_attachments",void 0),e([c()],N.prototype,"_featureTemplates",void 0),e([c()],N.prototype,"_filterText",void 0),e([c()],N.prototype,"_prompt",void 0),e([c()],N.prototype,"_spinner",void 0),e([c()],N.prototype,"_deleteButtonCommonInfo",null),e([c({readOnly:!0})],N.prototype,"activeWorkflow",null),e([c()],N.prototype,"allowedWorkflows",null),e([c()],N.prototype,"useDeprecatedCreateWorkflow",null),e([c()],N.prototype,"headingLevel",void 0),e([c()],N.prototype,"iconClass",void 0),e([c()],N.prototype,"label",null),e([c()],N.prototype,"labelOptions",null),e([c()],N.prototype,"layerInfos",null),e([c(),E("esri/widgets/Editor/t9n/Editor")],N.prototype,"messages",void 0),e([c(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),e([c(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],N.prototype,"messagesTemplates",void 0),e([c()],N.prototype,"snappingOptions",null),e([c()],N.prototype,"tooltipOptions",null),e([c()],N.prototype,"supportingWidgetDefaults",void 0),e([c()],N.prototype,"view",null),e([c(),W(["workflow-cancel","workflow-commit"])],N.prototype,"viewModel",void 0),e([c()],N.prototype,"visibleElements",void 0),e([d("visibleElements")],N.prototype,"castVisibleElements",null),e([T()],N.prototype,"_onSave",null),e([T()],N.prototype,"_onDelete",null),e([T()],N.prototype,"_onBack",null),e([T()],N.prototype,"_onAttachmentAdd",null),e([T()],N.prototype,"_onAttachmentUpdate",null),e([T()],N.prototype,"_onAttachmentDelete",null),N=e([p(x)],N);const V=N;export{V as default};