@arcgis/core 4.33.0-next.20250303 → 4.33.0-next.20250305

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 (158) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{b49af2e3a1a38a063ab9.js → 1bd4fe77ba6fb25322e7.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{2f818b9a6b1f2b61410d.js → 1e7a70a1871fea29169e.js} +27 -27
  4. package/assets/esri/core/workers/chunks/{3ebdd0701e77bb28c75d.js → 2079f9d28e4199714f22.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{0fd6a78b38b0e2dae8a5.js → 237a965bd41ba8903e03.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{618016fc1165bcfc2b0d.js → 42b862550c96cc1be956.js} +7 -9
  7. package/assets/esri/core/workers/chunks/4403b3f08907e88d0d91.js +1 -0
  8. package/assets/esri/core/workers/chunks/{4dbd4523281691401272.js → 4539a802cba77a7a7cc7.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{0e2d9cd4e8ee5a62b05c.js → 45eee326f7a649c5a15b.js} +7 -9
  10. package/assets/esri/core/workers/chunks/{99f90d085aa9eb13e4fb.js → 46fb6ba8900286d18b6f.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{2a44a6e75b2799246257.js → 4fb4884d2de42792abe3.js} +1 -1
  12. package/assets/esri/core/workers/chunks/5295e685ae839087c568.js +1 -0
  13. package/assets/esri/core/workers/chunks/{d60da671aba70485050e.js → 6e6422eda398774acbc7.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{c9cb8a6ff01275bec713.js → 77845cd5d824c1004bfa.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{a73a262ddc959a59819f.js → 7d3b2bdc75525d47389c.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{cc1aedb2b3aa3854b0de.js → 901c957c049f53318e87.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{654fe135d41af81daa13.js → 909be86782af3deb448e.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{7d93ff4f18fd21c7b9f2.js → 94f41ef15f6c61562e5e.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{8540fb31bd0b29ff1906.js → 968956284f44187f0622.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{92b48e3365d1cc933113.js → 96d2a0777f5c418055fb.js} +1 -1
  21. package/assets/esri/core/workers/chunks/988efc508c33ca341e49.js +1 -0
  22. package/assets/esri/core/workers/chunks/{56db71ea7eb8a5652d98.js → abfc5f9ac16c3e885c5f.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{856b03020b2dd047291d.js → ad9b3b83aa96db7b79ea.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{c3b2b05996e2008adbe3.js → afddb94ff4e1a70022c7.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{c409bb2acd846d3b1395.js → b2f9f0767dadf185120c.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{563594357f3648652a5c.js → ba917175ca2a6681501e.js} +1 -1
  27. package/assets/esri/core/workers/chunks/c03e6e35082beaec02a6.js +1 -0
  28. package/assets/esri/core/workers/chunks/{759781cad91d31ab7bc4.js → db4c110ab4c26c4b768c.js} +1 -1
  29. package/assets/esri/core/workers/chunks/dcb043986fb065de0366.js +1 -0
  30. package/assets/esri/core/workers/chunks/{05c80002c37002ac99e8.js → de16b771d2c8d816c738.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{3010a22d00f45fce5939.js → e0ac90b4ad8c36fb7d70.js} +1 -1
  32. package/assets/esri/core/workers/chunks/e3e049311bced533c853.js +1 -0
  33. package/assets/esri/core/workers/chunks/{5719471414810b6a9aec.js → e56647e61296643c5f84.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{1bc22af4cc4effcbcf2b.js → e6a5911ea21bef32834b.js} +1 -1
  35. package/assets/esri/core/workers/chunks/f4111bb5e5a4910b684a.js +1 -0
  36. package/assets/esri/core/workers/chunks/{12d798775a96a45aada2.js → f46c4a69ef2f763e905b.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{5e80e10b7c7e66dd861e.js → febae745a29a17ca130a.js} +1 -1
  38. package/chunks/Bufferer-CicaNej1.js +1 -1
  39. package/chunks/Clouds.glsl.js +19 -23
  40. package/chunks/DefaultMaterial.glsl.js +22 -22
  41. package/chunks/Distance2DCalculator-C1KHhZwD.js +1 -1
  42. package/chunks/Envelope.js +1 -1
  43. package/chunks/GeodeticDistanceCalculator-CcF1gMZX.js +1 -1
  44. package/chunks/ImageMaterial.glsl.js +1 -1
  45. package/chunks/OperatorClip.js +1 -1
  46. package/chunks/OperatorCut.js +1 -1
  47. package/chunks/OperatorGeodesicBuffer.js +1 -1
  48. package/chunks/OperatorGeodeticArea.js +1 -1
  49. package/chunks/OperatorMultiPartToSinglePart.js +1 -1
  50. package/chunks/OperatorProximity.js +1 -1
  51. package/chunks/OperatorShapePreservingProject.js +1 -1
  52. package/chunks/ProjectionTransformation.js +1 -1
  53. package/chunks/SideCalculator2D-BNwb5gvz.js +1 -1
  54. package/chunks/disjointOperator.js +1 -1
  55. package/core/Accessor.js +1 -1
  56. package/core/accessorSupport/decorators/subclass.js +1 -1
  57. package/core/accessorSupport/interfaces.js +1 -1
  58. package/core/arrayUtils.js +1 -1
  59. package/editing/sharedTemplates/executor/builders/support/builderUtils.js +1 -1
  60. package/editing/sharedTemplates/executor/createTemplateExecutor.js +1 -1
  61. package/editing/sharedTemplates/executor/support/createFeatureServiceEdit.js +5 -0
  62. package/editing/sharedTemplates/executor/support/createPresetServiceEdit.js +5 -0
  63. package/geometry/operators/extendOperator.js +1 -1
  64. package/geometry/operators/gx/operatorAutoComplete.js +1 -1
  65. package/geometry/operators/gx/operatorBuffer.js +1 -1
  66. package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
  67. package/geometry/operators/gx/operatorIntegrate.js +1 -1
  68. package/geometry/operators/gx/operatorLabelPoint.js +1 -1
  69. package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
  70. package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
  71. package/geometry/operators/gx/operatorSimplify.js +1 -1
  72. package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
  73. package/geometry/operators/gx/operatorUnion.js +1 -1
  74. package/geometry/operators/json/disjointOperator.js +1 -1
  75. package/geometry/operators/reshapeOperator.js +1 -1
  76. package/geometry/operators/support/apiConverter.js +1 -1
  77. package/geometry/operators/support/initNoPeFactory.js +1 -1
  78. package/geometry/operators/support/jsonConverter.js +1 -1
  79. package/interfaces.d.ts +20 -18
  80. package/layers/WMTSLayer.js +1 -1
  81. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  82. package/layers/graphics/dehydratedFeatures.js +1 -1
  83. package/layers/mixins/ArcGISImageService.js +1 -1
  84. package/layers/support/SubtypeSublayer.js +1 -1
  85. package/layers/support/featureLayerUtils.js +1 -1
  86. package/layers/support/wmtsUtils.js +1 -1
  87. package/package.json +1 -1
  88. package/request.js +1 -1
  89. package/rest/support/IdentifyParameters.js +1 -1
  90. package/support/revision.js +1 -1
  91. package/views/3d/analysis/Dimension/DimensionTool.js +1 -1
  92. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  93. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  94. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  95. package/views/3d/environment/Clouds.glsl.js +1 -1
  96. package/views/3d/environment/CloudsParameters.js +1 -1
  97. package/views/3d/environment/CloudsRenderer.js +1 -1
  98. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  99. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  100. package/views/3d/layers/GraphicsLayerView3D.js +1 -1
  101. package/views/3d/layers/I3SMeshView3D.js +1 -1
  102. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  103. package/views/3d/layers/MediaLayerView3D.js +1 -1
  104. package/views/3d/layers/SceneLayerView3D.js +1 -1
  105. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  106. package/views/3d/layers/support/FeatureTile.js +1 -1
  107. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  108. package/views/3d/layers/support/FeatureTileFetcher3DDebugger.js +1 -1
  109. package/views/3d/layers/support/projectExtentUtils.js +1 -1
  110. package/views/3d/support/StreamTextureCollection.js +1 -1
  111. package/views/3d/support/TextureCollection.js +1 -1
  112. package/views/3d/terrain/TerrainRenderer.js +1 -1
  113. package/views/3d/terrain/TerrainSurface.js +1 -1
  114. package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +7 -7
  115. package/views/3d/webgl-engine/core/shaderLibrary/util/DoublePrecision.glsl.js +5 -7
  116. package/views/3d/webgl-engine/core/shaderLibrary/util/LookupCloudsFromTextureArray.glsl.js +51 -0
  117. package/views/3d/webgl-engine/lib/GLMaterialParameters.js +5 -0
  118. package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
  119. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  120. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  121. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  122. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  123. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  124. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  125. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  126. package/views/View.js +1 -1
  127. package/views/animation/pointToPoint/apex/planning.js +1 -1
  128. package/views/support/LayerLayerViewInfo.js +5 -0
  129. package/views/support/LayerViewManager.js +5 -0
  130. package/views/webgl/FramebufferObject.js +1 -1
  131. package/views/webgl/TextureDescriptor.js +1 -1
  132. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  133. package/widgets/Editor/Edits.js +1 -1
  134. package/widgets/Editor/workflowUtils.js +1 -1
  135. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  136. package/widgets/Feature/FeatureRelationship.js +1 -1
  137. package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +1 -1
  138. package/widgets/Feature/support/featureUtils.js +1 -1
  139. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  140. package/widgets/FeatureForm/FieldInput.js +1 -1
  141. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  142. package/widgets/Features/FeaturesDrillIn.js +1 -1
  143. package/widgets/Features/FeaturesViewModel.js +1 -1
  144. package/widgets/Features.js +1 -1
  145. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeaturesDrillIn.js +1 -1
  146. package/widgets/UtilityNetworkTraceAnalysis/UtilityNetworkTraceAnalysisViewModel.js +1 -1
  147. package/widgets/VideoPlayer/VideoPlayerViewModel.js +1 -1
  148. package/widgets/support/UtilityNetworkAssociations/utils/createAssociation.js +1 -1
  149. package/assets/esri/core/workers/chunks/0e6d338b0937724763c7.js +0 -1
  150. package/assets/esri/core/workers/chunks/10118666a5a5b141ece6.js +0 -1
  151. package/assets/esri/core/workers/chunks/64d3e683872791eb6ae9.js +0 -1
  152. package/assets/esri/core/workers/chunks/7d120f8b01fe719eb257.js +0 -1
  153. package/assets/esri/core/workers/chunks/95047f145ebda65c3d8e.js +0 -1
  154. package/assets/esri/core/workers/chunks/960b12a6fd5b6933212f.js +0 -1
  155. package/assets/esri/core/workers/chunks/af005704f23088db3ded.js +0 -1
  156. package/editing/sharedTemplates/executor/support/createServiceEdit.js +0 -5
  157. package/views/3d/webgl-engine/core/shaderLibrary/util/LookupCubemapFromTextureArray.glsl.js +0 -39
  158. package/views/LayerViewManager.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{isPromiseLike as d,debounce as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as F}from"../../editing/templateUtils.js";import{createTemplateExecutor as _}from"../../editing/sharedTemplates/executor/createTemplateExecutor.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{getDisplayedSymbol as V}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as I}from"../../views/draw/support/helpMessageUtils.js";import k from"../../views/draw/support/HighlightHelper.js";import S from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as A}from"../../views/support/HighlightDefaults.js";import P from"./CreateFeaturesWorkflowData.js";import{isModelUpload as E,handleModelUpload as H}from"./modelUploadUtils.js";import T from"./Workflow.js";import{createToolFromGeometryType as j,setRelationshipFields as U,startCreatingNewFeature as L,findLayerInfo as x,updateGraphicSymbolWhenRequired as O,isTerminalUpdateEventType as R,getVisualVariableAttributes as W,startUpdatingFeatureGeometry as D,createWorkflowSteps as z,avoidFeatureTemplateSelectionWithOnlyOneItem as N,getCreationAttributes as G,getFullTemplateForCreationInfo as Z,getServiceLayersById as K,prepareAttachmentsForCreateFeaturesWorkflow as q,showProgressCursor as B,setUpSketchCreateWatchers as J,setVisualVariablesAndElevationInfoForUpdate as Q,visualVariableInteractiveUpdate as X}from"./workflowUtils.js";import Y from"../FeatureForm/FeatureFormViewModel.js";import $ from"../Sketch/SketchViewModel.js";var ee;const te=Symbol(),ae=Symbol(),ie=Symbol(),re=Symbol(),se={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let oe=ee=class extends T{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new Y,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some((e=>!!this.data.getEditsForPendingFeature(e)?.modified)))return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!E(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return I("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=j(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...se[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([ie])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find((e=>this._hasValidationErrors(e)));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e))}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,applyEditsFeatureServiceCallback:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new S,u=s?.layer,h=u?d.findEditorItemForLayer(u):void 0,p=new ee({data:new P({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:d,templateExecutorInfo:c}=e;c?.completionResult&&U(c.completionResult.relationships);const u=d&&F(d)&&c?.completionResult;if(n){if(ce(s),u){const e=he(c.completionResult.edits,l);await i(d.featureService,e,{globalIdUsed:!0,gdbVersion:d.layer.gdbVersion??void 0})}else{const e=ue(s,l);await a(o,e,{globalIdUsed:!0})}return}const h=u?await i(d.featureService,c.completionResult.edits,{gdbVersion:d.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];h&&l.size>0&&await Promise.all(h.map((e=>{if(e?.addFeatureResults)return t(o,de(s,e.addFeatureResults,o,l))})))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,i((()=>e.opacity=t))}async _startCreating(){this.removeHandles(ae);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new";const a=await L(this._sketchViewModel,e,this._webStyleCache);this.addHandles(a,ae)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:o,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;n(this._featureFormHandle);const f=e.sourceLayer,w=x(p,f),g=w?.formTemplate,y=m.spatialReference;o.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||c.activeWorkflow?.previous(),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>h.addFile(e,t))),await O(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",(async()=>{v?.updateAttributes(o.getValues()),await O(e,s,"2d"===m.type?m.scale:null)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&R(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()})),u((()=>o.feature?.sourceLayer),(t=>e.sourceLayer=t)),u((()=>[o.feature,o.submittable]),(()=>this._stashValidationState()))]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=e.sourceLayer??r.layer;return M(n)?void 0:(this._visualVariableAttributes=W(e),D({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=z(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(E(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([ie,te,ae,re]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return N(a,i)}static _configureSketchViewModel(e){const{data:t}=e,a=e._webStyleCache,{creationInfo:s,viewModel:o}=t,{view:n}=o,l=e._sketchViewModel,d=[];if(!n)return i();if("2d"===n.type){s&&d.push(e._fadeExistingFeatures(s.layer));const t=c(((e,t)=>Promise.all(e.map((e=>O(e,a,t))))));d.push(u((()=>n.scale),(e=>t(l.layer.graphics,e))))}const p=G(t.fullTemplate,s?.attributeOverrides),m=async i=>{if("start"!==i.state||e.hasHandles(ae)||e.addHandles(await J({creationAttributes:p,data:t,sketchViewModel:l,view:n,webStyleCache:a}),ae),"cancel"!==i.state&&"complete"!==i.state||e.removeHandles(ae),"cancel"===i.state&&null!==n.activeTool&&n.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===i.state&&i.graphic){const t=await e._processEdits(i.graphic,{scale:"2d"===n.type?n.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});t&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:t}))}},f=async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e;if(a.graphics.length>1)return void await e._clearSelectedFeature();const d=a.graphics[0];if("complete"===a.state){const{submittable:t}=r;if(e.numPendingFeatures!==s?.maxFeatures&&t||r.submit(),await e._clearSelectedFeature(),"add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),!a.aborted&&n.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===a.state)return d.sourceLayer??=t.creationInfo?.layer,await Q({sketchViewModel:l,graphic:d,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===a.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;await X(n,d,a,t,e._webStyleCache);const i=d.attributes,{rotation:s,size:o}=t;if(null!=s){const{field:e}=s;r.setValue(e,i[e])}if(null!=o){const{field:e}=o;r.setValue(e,i[e])}}}},w=async a=>{if(a.graphics.forEach((e=>{t.removePendingFeature(e)})),!E(t.creationInfo))return e._startCreating()},g=async()=>{if(E(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};d.push(l.on("create",(t=>e._updatingHandles.addPromise(m(t)))),l.on("update",(t=>e._updatingHandles.addPromise(f(t)))),l.on("delete",(t=>e._updatingHandles.addPromise(w(t)))),h((()=>!e.numPendingFeatures),(()=>e._updatingHandles.addPromise(g()))),i((()=>{l.cancel()})),ne(l,t),...le(t));const y=r(d);return l.addHandles(y),y}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new $({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})),u((()=>this.numPendingFeatures>0),(e=>this._sketchViewModel.updateOnGraphicClick=e),p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_featureFormViewModel:i}=this,{layerInfos:r,view:s}=a.viewModel;i.arcadeEditType="INSERT",i.map=s?.map,i.spatialReference=s?.spatialReference;const{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}const n=this.sketchViewModel.layer;n.remove(e);const{executor:l}=o,c=l(e.geometry,"completion"),u=d(c)?await c:c;o.completionResult=u,U(u.relationships);for(const d of u.edits){let e=null;if(d.addFeatures)for(const a of d.addFeatures){const i=a.clone();i.geometry=null,a.symbol=await V(a,t),n.add(a),a.sourceLayer!==e?.layer&&(e=x(r,a.sourceLayer)),await this._addAndInitializeEdits(a,i,e)}}i.feature=null,await m((()=>!i.updating));return u.edits.reduce(((e,t)=>e+(t.addFeatures?.length??0)),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a){const{data:i,_featureFormViewModel:r}=this,{layerInfos:s}=i.viewModel,o=i.addPendingFeature(e,t);a??=x(s,e.sourceLayer),r.feature=e,r.formTemplate=a?.formTemplate,await m((()=>!r.updating)),o.submittable=r.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(ie))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[];if(this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=l.findEditorItemForLayer(o.layer),null===e.fullTemplate&&o.template){const t=await Z(o,c);e.fullTemplate=t,t&&F(t)&&(e.templateExecutorInfo={completionResult:null,executor:await _(t),serviceLayersById:await K(o.layer,c)})}s.allowDeleteKey=!e.isSharedTemplateWorkflow,q(d),f.push(u((()=>d.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const w=B(c);f.push(w);const g=M(o.layer);try{if(g){const{template:e}=o;if(e&&v(e))throw new a("Shared templates are not yet supported");const i=h??new t({attributes:{...e?.prototype.attributes,...o.attributeOverrides},sourceLayer:m});await this._startUpdating({feature:i})}else f.push(ee._configureSketchViewModel(this)),h?(E(o)&&o.geometryToPlace&&(h.attributes=G(e.fullTemplate,o.attributeOverrides)),s.layer.add(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{w.remove()}const y=i((()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)})),b=u((()=>c?.timeZone),(e=>{this._featureFormViewModel.timeZone=e,this.data.timeZone=e}),p),V=i((()=>{E(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles([i((()=>d.fileInfos.removeAll())),r(f),V,y,b],ie)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),re),await m((()=>null==e?.activeTool),t.signal),t.abort()}};function ne(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new C({layer:e.layer}),s().add(a),a),n=()=>{null!=a&&(s().remove(a),a=l(a))};return r([u((()=>{const e=t.creationInfo?.layer,a=s().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return n();a??=o(),a.enabled=t}),f),i(n)])}function le(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new k({view:t});a.push(u((()=>e.selectedPendingFeature),((e,t)=>{r.remove(e),r.add(t)})),i((()=>r.destroy())))}const r=new k({view:t,highlightName:A});return a.push(u((()=>e.temporaryHighlightFeature),(e=>{r.removeAll(),r.add(e)})),i((()=>r.destroy()))),a}function de(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function ce(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function ue(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function he(e,t){return e.map((e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e}))}e([g()],oe.prototype,"createFeatureState",void 0),e([g()],oe.prototype,"data",void 0),e([g({constructOnly:!0})],oe.prototype,"isNested",void 0),e([g()],oe.prototype,"featureFormViewModel",null),e([g()],oe.prototype,"hasPendingEdits",null),e([g()],oe.prototype,"hasPreviousStep",null),e([g()],oe.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],oe.prototype,"helpMessage",null),e([g()],oe.prototype,"layer",null),e([g()],oe.prototype,"parent",null),e([g()],oe.prototype,"parentLayer",null),e([g()],oe.prototype,"keyboardCancellationEnabled",null),e([g()],oe.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],oe.prototype,"shouldShowAttachments",null),e([g()],oe.prototype,"shouldAllowAttachmentEditing",null),e([g()],oe.prototype,"sketchViewModel",null),e([g()],oe.prototype,"availableCreateTools",null),e([g()],oe.prototype,"_attachmentsActive",null),oe=ee=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],oe);const pe=oe;export{pe as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{isPromiseLike as d,debounce as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as F}from"../../editing/templateUtils.js";import{createTemplateExecutor as _}from"../../editing/sharedTemplates/executor/createTemplateExecutor.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{getDisplayedSymbol as V}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as I}from"../../views/draw/support/helpMessageUtils.js";import k from"../../views/draw/support/HighlightHelper.js";import S from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as A}from"../../views/support/HighlightDefaults.js";import P from"./CreateFeaturesWorkflowData.js";import{isModelUpload as E,handleModelUpload as H}from"./modelUploadUtils.js";import T from"./Workflow.js";import{createToolFromGeometryType as j,setRelationshipFields as U,startCreatingNewFeature as L,findLayerInfo as x,updateGraphicSymbolWhenRequired as O,isTerminalUpdateEventType as R,getVisualVariableAttributes as W,startUpdatingFeatureGeometry as D,createWorkflowSteps as z,avoidFeatureTemplateSelectionWithOnlyOneItem as G,getCreationAttributes as N,getFullTemplateForCreationInfo as Z,getServiceLayersById as K,prepareAttachmentsForCreateFeaturesWorkflow as q,showProgressCursor as B,setUpSketchCreateWatchers as J,setVisualVariablesAndElevationInfoForUpdate as Q,visualVariableInteractiveUpdate as X}from"./workflowUtils.js";import Y from"../FeatureForm/FeatureFormViewModel.js";import $ from"../Sketch/SketchViewModel.js";var ee;const te=Symbol(),ae=Symbol(),ie=Symbol(),re=Symbol(),se={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let oe=ee=class extends T{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new Y,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some((e=>!!this.data.getEditsForPendingFeature(e)?.modified)))return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!E(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return I("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=j(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...se[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([ie])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find((e=>this._hasValidationErrors(e)));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e))}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,applyEditsFeatureServiceCallback:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new S,u=s?.layer,h=u?d.findEditorItemForLayer(u):void 0,p=new ee({data:new P({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:d,templateExecutorInfo:c}=e;c?.completionResult&&U(c.completionResult.relationships);const u=d&&F(d)&&c?.completionResult;if(n){if(ce(s),u){const e=he(c.completionResult.edits,l);await i(d.featureService,e,{globalIdUsed:!0,gdbVersion:d.layer.gdbVersion??void 0})}else{const e=ue(s,l);await a(o,e,{globalIdUsed:!0})}return}const h=u?await i(d.featureService,c.completionResult.edits,{gdbVersion:d.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];h&&l.size>0&&await Promise.all(h.map((e=>{if(e?.addFeatureResults)return t(o,de(s,e.addFeatureResults,o,l))})))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,i((()=>e.opacity=t))}async _startCreating(){this.removeHandles(ae);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await L(this._sketchViewModel,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:o,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;n(this._featureFormHandle);const f=e.sourceLayer,w=x(p,f),g=w?.formTemplate,y=m.spatialReference;o.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||c.activeWorkflow?.previous(),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>h.addFile(e,t))),await O(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",(async()=>{v?.updateAttributes(o.getValues()),await O(e,s,"2d"===m.type?m.scale:null)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&R(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()})),u((()=>o.feature?.sourceLayer),(t=>e.sourceLayer=t)),u((()=>[o.feature,o.submittable]),(()=>this._stashValidationState()))]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=e.sourceLayer??r.layer;return M(n)?void 0:(this._visualVariableAttributes=W(e),D({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=z(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(E(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([ie,te,ae,re]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return G(a,i)}static _configureSketchViewModel(e){const{data:t}=e,a=e._webStyleCache,{creationInfo:s,viewModel:o}=t,{view:n}=o,l=e._sketchViewModel,d=[];if(!n)return i();if("2d"===n.type){s&&d.push(e._fadeExistingFeatures(s.layer));const t=c(((e,t)=>Promise.all(e.map((e=>O(e,a,t))))));d.push(u((()=>n.scale),(e=>t(l.layer.graphics,e))))}const p=N(t.fullTemplate,s?.attributeOverrides),m=u((()=>l.createGraphic),(i=>{i&&!e.hasHandles(ae)&&e._updatingHandles.addPromise(J({creationAttributes:p,data:t,sketchViewModel:l,view:n,webStyleCache:a}).then((t=>e.addHandles(t,ae))))})),f=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(ae),"cancel"===t.state&&null!==n.activeTool&&n.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===n.type?n.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},w=async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e;if(a.graphics.length>1)return void await e._clearSelectedFeature();const d=a.graphics[0];if("complete"===a.state){const{submittable:t}=r;if(e.numPendingFeatures!==s?.maxFeatures&&t||r.submit(),await e._clearSelectedFeature(),"add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),!a.aborted&&n.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===a.state)return d.sourceLayer??=t.creationInfo?.layer,await Q({sketchViewModel:l,graphic:d,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===a.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;await X(n,d,a,t,e._webStyleCache);const i=d.attributes,{rotation:s,size:o}=t;if(null!=s){const{field:e}=s;r.setValue(e,i[e])}if(null!=o){const{field:e}=o;r.setValue(e,i[e])}}}},g=async a=>{if(a.graphics.forEach((e=>{t.removePendingFeature(e)})),!E(t.creationInfo))return e._startCreating()},y=async()=>{if(E(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};d.push(m,l.on("create",(t=>e._updatingHandles.addPromise(f(t)))),l.on("update",(t=>e._updatingHandles.addPromise(w(t)))),l.on("delete",(t=>e._updatingHandles.addPromise(g(t)))),h((()=>!e.numPendingFeatures),(()=>e._updatingHandles.addPromise(y()))),i((()=>{l.cancel()})),ne(l,t),...le(t));const v=r(d);return l.addHandles(v),v}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new $({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})),u((()=>this.numPendingFeatures>0),(e=>this._sketchViewModel.updateOnGraphicClick=e),p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_featureFormViewModel:i}=this,{layerInfos:r,view:s}=a.viewModel;i.arcadeEditType="INSERT",i.map=s?.map,i.spatialReference=s?.spatialReference;const{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}const n=this.sketchViewModel.layer;n.remove(e);const{executor:l}=o,c=l(e.geometry,"completion"),u=d(c)?await c:c;o.completionResult=u,U(u.relationships);for(const d of u.edits){let e=null;if(d.addFeatures)for(const a of d.addFeatures){const i=a.clone();i.geometry=null,a.symbol=await V(a,t),n.add(a),a.sourceLayer!==e?.layer&&(e=x(r,a.sourceLayer)),await this._addAndInitializeEdits(a,i,e)}}i.feature=null,await m((()=>!i.updating));return u.edits.reduce(((e,t)=>e+(t.addFeatures?.length??0)),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a){const{data:i,_featureFormViewModel:r}=this,{layerInfos:s}=i.viewModel,o=i.addPendingFeature(e,t);a??=x(s,e.sourceLayer),r.feature=e,r.formTemplate=a?.formTemplate,await m((()=>!r.updating)),o.submittable=r.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(ie))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[];if(this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=l.findEditorItemForLayer(o.layer),null===e.fullTemplate&&o.template){const t=await Z(o,c);e.fullTemplate=t,t&&F(t)&&(e.templateExecutorInfo={completionResult:null,executor:await _(t),serviceLayersById:await K(o.layer,c)})}s.allowDeleteKey=!e.isSharedTemplateWorkflow,q(d),f.push(u((()=>d.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const w=B(c);f.push(w);const g=M(o.layer);try{if(g){const{template:e}=o;if(e&&v(e))throw new a("Shared templates are not yet supported");const i=h??new t({attributes:{...e?.prototype.attributes,...o.attributeOverrides},sourceLayer:m});await this._startUpdating({feature:i})}else f.push(ee._configureSketchViewModel(this)),h?(E(o)&&o.geometryToPlace&&(h.attributes=N(e.fullTemplate,o.attributeOverrides)),s.layer.add(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{w.remove()}const y=i((()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)})),b=u((()=>c?.timeZone),(e=>{this._featureFormViewModel.timeZone=e,this.data.timeZone=e}),p),V=i((()=>{E(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles([i((()=>d.fileInfos.removeAll())),r(f),V,y,b],ie)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),re),await m((()=>null==e?.activeTool),t.signal),t.abort()}};function ne(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new C({layer:e.layer}),s().add(a),a),n=()=>{null!=a&&(s().remove(a),a=l(a))};return r([u((()=>{const e=t.creationInfo?.layer,a=s().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return n();a??=o(),a.enabled=t}),f),i(n)])}function le(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new k({view:t});a.push(u((()=>e.selectedPendingFeature),((e,t)=>{r.remove(e),r.add(t)})),i((()=>r.destroy())))}const r=new k({view:t,highlightName:A});return a.push(u((()=>e.temporaryHighlightFeature),(e=>{r.removeAll(),r.add(e)})),i((()=>r.destroy()))),a}function de(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function ce(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function ue(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function he(e,t){return e.map((e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e}))}e([g()],oe.prototype,"createFeatureState",void 0),e([g()],oe.prototype,"data",void 0),e([g({constructOnly:!0})],oe.prototype,"isNested",void 0),e([g()],oe.prototype,"featureFormViewModel",null),e([g()],oe.prototype,"hasPendingEdits",null),e([g()],oe.prototype,"hasPreviousStep",null),e([g()],oe.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],oe.prototype,"helpMessage",null),e([g()],oe.prototype,"layer",null),e([g()],oe.prototype,"parent",null),e([g()],oe.prototype,"parentLayer",null),e([g()],oe.prototype,"keyboardCancellationEnabled",null),e([g()],oe.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],oe.prototype,"shouldShowAttachments",null),e([g()],oe.prototype,"shouldAllowAttachmentEditing",null),e([g()],oe.prototype,"sketchViewModel",null),e([g()],oe.prototype,"availableCreateTools",null),e([g()],oe.prototype,"_attachmentsActive",null),oe=ee=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],oe);const pe=oe;export{pe as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{debounce as i}from"../../core/promiseUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{attributesAreEquivalent as o}from"./support/editsUtils.js";function a(e){return null==e?null:JSON.stringify(e)}let l=class extends t{constructor(e){super(e),this._stagedForDelete=!1,this.feature=null,this.initialFeature=null,this.submittable=!1,this.displayTitle=null,this._debouncedRefreshDisplayTitle=i(this._refreshDisplayTitle.bind(this),100)}get attributesModified(){return!o(this.initialFeature?.attributes,this.feature?.attributes)}get geometryModified(){return this._stringifyGeometry(this.feature)!==this._stringifyGeometry(this.initialFeature)}get stagedForDelete(){return this._stagedForDelete}get modified(){return this.attributesModified||this.geometryModified||this._stagedForDelete}set timeZone(e){this._set("timeZone",e),this._debouncedRefreshDisplayTitle()}stageDelete(){this._stagedForDelete=!0}unstageDelete(){this._stagedForDelete=!1}trackChanges(e=this.feature){this.initialFeature=e?.clone(),this._debouncedRefreshDisplayTitle()}updateAttributes(e){const{feature:t}=this;t&&(t.attributes=e,this.notifyChange("attributesModified")),this._debouncedRefreshDisplayTitle()}updateGeometry(e){const{feature:t}=this;t&&(t.geometry=e,this.notifyChange("geometryModified"))}_stringifyGeometry(e){const t=e?.geometry;return a("mesh"===t?.type?{transform:t.transform,vertexSpace:t.vertexSpace}:t)}async _refreshDisplayTitle(e){const t=this.feature,i=t?.sourceLayer;if(!i||!("getFeatureTitle"in i))return;const r=await i.getFeatureTitle(t,{fetchMissingFields:!1,timeZone:this.timeZone});e.aborted||(this.displayTitle=""===r?null:r)}};e([r()],l.prototype,"_stagedForDelete",void 0),e([r()],l.prototype,"attributesModified",null),e([r()],l.prototype,"feature",void 0),e([r()],l.prototype,"geometryModified",null),e([r()],l.prototype,"initialFeature",void 0),e([r()],l.prototype,"modified",null),e([r()],l.prototype,"submittable",void 0),e([r()],l.prototype,"displayTitle",void 0),e([r()],l.prototype,"timeZone",null),l=e([s("esri.widgets.Editor.Edits")],l);const n=l;export{n as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{debounce as i,ignoreAbortErrors as r}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{attributesAreEquivalent as a}from"./support/editsUtils.js";function l(e){return null==e?null:JSON.stringify(e)}let n=class extends t{constructor(e){super(e),this._stagedForDelete=!1,this.feature=null,this.initialFeature=null,this.submittable=!1,this.displayTitle=null,this._debouncedRefreshDisplayTitle=i(this._refreshDisplayTitle.bind(this),100)}get attributesModified(){return!a(this.initialFeature?.attributes,this.feature?.attributes)}get geometryModified(){return this._stringifyGeometry(this.feature)!==this._stringifyGeometry(this.initialFeature)}get stagedForDelete(){return this._stagedForDelete}get modified(){return this.attributesModified||this.geometryModified||this._stagedForDelete}set timeZone(e){this._set("timeZone",e),this._debouncedRefreshDisplayTitle()}stageDelete(){this._stagedForDelete=!0}unstageDelete(){this._stagedForDelete=!1}trackChanges(e=this.feature){this.initialFeature=e?.clone(),this._debouncedRefreshDisplayTitle()}updateAttributes(e){const{feature:t}=this;t&&(t.attributes=e,this.notifyChange("attributesModified")),r(this._debouncedRefreshDisplayTitle())}updateGeometry(e){const{feature:t}=this;t&&(t.geometry=e,this.notifyChange("geometryModified"))}_stringifyGeometry(e){const t=e?.geometry;return l("mesh"===t?.type?{transform:t.transform,vertexSpace:t.vertexSpace}:t)}async _refreshDisplayTitle(e){const t=this.feature,i=t?.sourceLayer;if(!i||!("getFeatureTitle"in i))return;const r=await i.getFeatureTitle(t,{fetchMissingFields:!1,timeZone:this.timeZone});e.aborted||(this.displayTitle=""===r?null:r)}};e([s()],n.prototype,"_stagedForDelete",void 0),e([s()],n.prototype,"attributesModified",null),e([s()],n.prototype,"feature",void 0),e([s()],n.prototype,"geometryModified",null),e([s()],n.prototype,"initialFeature",void 0),e([s()],n.prototype,"modified",null),e([s()],n.prototype,"submittable",void 0),e([s()],n.prototype,"displayTitle",void 0),e([s()],n.prototype,"timeZone",null),n=e([o("esri.widgets.Editor.Edits")],n);const u=n;export{u as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import t from"../../Graphic.js";import{addMany as r,equals as n}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import"../../core/has.js";import o from"../../core/Error.js";import{handlesGroup as a,makeHandle as s,abortHandle as l}from"../../core/handleUtils.js";import{clone as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{whenOrAbort as d,throwIfAborted as y,debounce as f,isPromiseLike as m}from"../../core/promiseUtils.js";import{watch as g,on as h,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as b}from"../../core/screenUtils.js";import{diff as v}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as S,isSharedGroupTemplate as j,isSharedPresetTemplate as I,isStandardFeatureTemplate as T,isSharedFeatureTemplate as V,getAllStandardFeatureTemplatesForLayer as U,isSharedTemplate as L}from"../../editing/templateUtils.js";import k from"../../editing/sharedTemplates/SharedTemplate.js";import{getSharedTemplateProvider as F}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import O from"../../layers/GraphicsLayer.js";import{featureHasFields as A,fixFields as x,getDisplayFieldName as M}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as P}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as C}from"../../renderers/support/lengthUtils.js";import{getTransformationType as R,TransformationType as E}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import G from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import Z from"../../symbols/SimpleMarkerSymbol.js";import{to3D as q}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as B}from"../../symbols/support/symbolUtils.js";import{getServices as N}from"../../undoredo/support/Services.js";import{GraphicState as Q}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as J}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as W}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as H,filterGraphicHits as K}from"../../views/support/hitTestSelectUtils.js";import{isDrawGraphicTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>u.getLogger("esri.widgets.Editor.workflowUtils");function $(e){return"update"===e.type}function _(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!oe(t.renderer))return{rotation:null,size:null};let r=null,n=null;const i=t.renderer.getVisualVariablesForType("rotation").filter((e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression));1===i.length&&(r=ee(i[0],t));const o=t.renderer.getVisualVariablesForType("size").filter((e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&R(e)===E.RealWorldSize));return 1===o.length&&(n=ne(o[0],t)),{rotation:r,size:n}}function ee(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)),o=i&&1===i.length?i[0].type:"double",a={initial:0,current:0};return{field:n,fieldType:o,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(a.current=a.initial-r*e,ie((a.current+360)%360,o)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function te(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 re(e,t,r){if(null==t)return 0;const{symbol:n}=q(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 Math.min(Me.icon,(await e(i,Me.icon))[0])||Me.icon}case"text":return Me.text;case"line":return Me.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return te(await t(i,e.scale/Me.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/Me.viewScaleSizeFactor;default:return 0}}function ne(e,t){const r=e.field,n=e.axis,i=t.fields&&t.fields.filter((e=>e.name===r)),o=i&&1===i.length?i[0].type:"double",a={initial:0,current:0},s=C[e.valueUnit]??1;let l;return l="area"===e.valueRepresentation?e=>(e*s/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*s/2:e=>e*s,{field:r,fieldType:o,getDefaultValue:async(e,t)=>ie(l(await re(t,e,n)),o),getValue:(e,t)=>(a.initial||(a.initial=t.pixelSizeAt(t.center)),a.current=a.initial*e,ie(a.current,o)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,displayUnit:Ce(e.valueUnit),axis:e.axis}}function ie(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 oe(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 ae(e,t,r){const n=await B(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=v(e.symbol,n)&&(e.symbol=n)}function se(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:J,optionsPerTool:r};if(S(t)){const i=t.defaultTool,o=j(t)?t.definition?.inputGeometryType??e:e;switch(i){case"freehand":case"stream-line":return{tool:"polyline"===o?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===o?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const i=t.drawingTool;if("circle"===i||"ellipse"===i)return r.get("circle").preserveAspectRatio="circle"===i,{tool:"circle",createOptions:n};if("rectangle"===i)return{tool:"rectangle",createOptions:n};if("freehand"===i)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function le(e,t,r){const{creationInfo:n,fullTemplate:i}=t;if(!n)throw new o("No creation info provided.");const a=n.layer,s=me(i,n.attributeOverrides),{view:l}=e,c="2d"===l?.type;j(i)||I(i)||await ge(e,a,s,r,c?l.scale:null);const{capabilities:u}=a;e.layer.elevationInfo=a.elevationInfo;const p=se(a.geometryType,i);return e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:a},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==n.geometryToPlace?await e.create(p.tool):await e.place(n.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:a}}),ce({creationAttributes:s,data:t,sketchViewModel:e,view:l,webStyleCache:r})}async function ce(e){return a([await ue(e),await pe(e)])}async function ue({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:i}){const{creationInfo:o}=t,{fullTemplate:a}=t;if(!o||"2d"!==n?.type||j(a)||I(a))return null;const s=f((t=>ge(r,o.layer,e,i,t)));return g((()=>n.scale),(e=>s(e)))}async function pe({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:i}=t;if(!i)return null;const l=r.activeComponent;if(!n||!X(l))return Y().error(new o("Failed to set up template feedback.")),null;const c=new O({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=i,d=n.theme?.accentColor??new e([255,165,0,1]);return a([h((()=>l),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=l.graphic?.geometry;if(!e||!de(e))return;const t=u(e,"digitizing");if(!m(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=ye(e,d);t&&c.add(t)}}})),s((()=>{n.map.remove(c),c.destroy()}))])}function de(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return n(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function ye(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new Z({angle:0,color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new G({color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}async function fe(e,t){const r=await N(t).load(),n=P(e)?e.parent:e,i=r.tablesAndLayersLookup.get(n);if(!i)return new Map;const o=new Map;for(const a of i.layersAndTables)p(o,a.layerId,(()=>[])).push(a);return o}function me(e,t={}){return j(e)||I(e)?{}:T(e)?{...e.prototype.attributes,...t}:V(e)?{...e.definition?.defaultValues,...t}:{...t}}async function ge(e,r,n,i,o){const a=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=_(a);let c=await B(a,{useSourceLayer:!0,webStyleCache:i,scale:o}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await B(a,{useSourceLayer:!0,webStyleCache:i,scale:o})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}he(e.tooltipOptions,l,s)}function he(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 we(e,t){return e?.find((e=>e.layer===t))}async function be(e,t,r,n){switch(t.type){case"3d":return ve(e,t,r,n);case"2d":return Se(e,t,r,n)}}async function ve(e,t,n,i){if(0===e.length)return[];const{updatable:o,graphicsByLayer:a}=await n.async((async()=>{const{results:r}=await d(H(t,n),i),o=new Map,a=e=>{const t=e.layer,r=o.get(t);if(!r){const e=new Array;return o.set(t,e),e}return r};K(r).forEach((({graphic:e})=>a(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&o.has(t)));return 0!==s.length&&n.stopPropagation(),{updatable:s,graphicsByLayer:o}}));return d(Promise.allSettled(o.map((async({layer:e})=>{const t=a.get(e),n=je(e);if(t.every((e=>A(n,e))))return t;const o=[];for(const i of t){o.push(i.getObjectId());const e=Object.keys(i.attributes);r(n,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=o,s.outFields=x(e.fieldsIndex,n),e.queryFeatures(s,{signal:i}).then((({features:e})=>e))}))),i)}async function Se(e,t,r,n){if(0===e.length)return[];const{mapPoint:i}=r;if(null==i)return[];let o=null;const a=await r.async((async()=>{const{results:i}=await d(t.hitTest(r),n);if(0===i.length)return[];const a=new Set;o=K(i),o.forEach((({graphic:e})=>e&&a.add(e.layer)));const s=e.filter((e=>a.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return d(Promise.allSettled(a.map((async({layer:e})=>{const a=e.createQuery();a.returnGeometry=!0,a.outFields=je(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;a.geometry=W(i,s,t),a.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(a,{signal:n});return o?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),n)}function je(e){return x(e.fieldsIndex,[e.objectIdField,M({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ie(e,t,r){const{sourceLayer:n}=e,i=n.createQuery();i.objectIds=[e.getAttribute(n.objectIdField)],i.outFields=["*"],i.returnM=n.capabilities.data.supportsM,i.returnZ=n.capabilities.data.supportsZ,"scene"===n.type&&null!=n.infoFor3D||(i.outSpatialReference=t);const o=await n.queryFeatures(i,{signal:r});y(r);return o.features[0]}async function Te(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:i}=e;await Ve(e);const o={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(o.enableRotation=null!=i.rotation,o.enableScaling=null!=i.size),r.update(t,o)}async function Ve(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:i,webStyleCache:o}=e;let a=!1;const{rotation:s,size:l}=i;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),a=!0}}if(a){const e="2d"===r.view?.type?r.view.scale:null;await ae(t,o,e)}he(r.tooltipOptions,l,s),r.layer.elevationInfo=n.elevationInfo}function Ue(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Le(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function ke(e,t,r,n,i){if(null==t.geometry||"point"!==t.geometry?.type)return;const o=n.rotation,a=Ue(r.toolEventInfo);if(null!=o&&null!=a){const{field:r,getValue:n}=o;"rotate-stop"===a.type?(o.isUpdatingInteractively=!1,o.setInitialValue(t.getAttribute(r))):(o.isUpdatingInteractively=!0,t.setAttribute(r,n(a.angle,e)))}const s=n.size,l=Le(r.toolEventInfo);if(null!=s&&null!=l){const{field:r,getValue:n}=s;"scale-stop"===l.type?(s.isUpdatingInteractively=!1,s.setInitialValue(t.getAttribute(r))):(s.isUpdatingInteractively=!0,t.setAttribute(r,n(l.xScale,e)))}await ae(t,i,"2d"===e.type?e.scale:null)}async function Fe({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:i,onUpdate:o,webStyleCache:c,addUpdatingPromise:u,addHandle:p}){await ae(t,c,"2d"===i.type?i.scale:null);let d=null;if("2d"===n?.view?.type){const e=f((e=>ae(t,c,e)));d=g((()=>n?.view?.scale),(t=>e(t)))}const y=t.sourceLayer,m=Ge(i,y);await Te({graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:c});let h=null;m.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,S=g((()=>e.attributes),(async e=>{let r=!1;for(const n in e){const i=e[n];i!==t.getAttribute(n)&&(t.setAttribute(n,i),null==b||b.isUpdatingInteractively||b.field!==n||b.setInitialValue(i),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(i),(null==h||h.requiredFields.includes(n))&&(r=!0))}r&&await ae(t,c,"2d"===i.type?i.scale:null)})),j=n.on("update",(async e=>{const t=e.graphics[0],a={graphic:t,sketchViewModel:n,sourceLayer:y,visualVariables:r,webStyleCache:c};if("complete"===e.state){if(null===i.activeTool)return Te(a);const e=new AbortController,t=l(e);return p(t),u(w((()=>null===i.activeTool),e.signal).then((()=>(e.abort(),Te(a)))))}await ke(i,t,e,r,c),o(Ze(t),e)})),I=n.on(["undo","redo"],(async e=>{o(Ze(e.graphics[0]),e)}));return a([I,j,s((()=>n.cancel())),S,d])}async function Oe(e,t,r){const n=e.view;e.layer.add(r);const o=t.sourceLayer,l=t.layer,c=t.getAttribute(l.objectIdField);let u=null;function p(e){u?.abort(),u=i((async t=>{const r=await Ge(n,o);y(t),r.setVisibility?.(c,e)}))}return await xe(n,r),p(!1),a([Ae(n,r,(e=>p(!e))),s((async()=>{p(!0);try{const e=await Ge(n,o);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function Ae(e,t,r){if("3d"===e.type){const n=new Q({graphic:t});return a([e.trackGraphicState(n),g((()=>n.displaying),r)])}return g((()=>t.visible),r)}async function xe(e,t){if("3d"===e.type){const r=new Q({graphic:t}),n=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),n.remove()}else await w((()=>t.visible))}const Me={icon:b(24),text:b(12),line:b(1),viewScaleSizeFactor:100};function Pe(e,t,r){let n=!1;return e.filter((e=>!!n||(n=e===t,n))).map((e=>r[e]()))}function ze(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,n=U(e);1===n.length&&"scene"!==e.type&&(r.template=n[0],t.shift())}return t}function Ce(e){return"unknown"===e?null:e}function Re(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const Ee=e=>/-stop/.test(e)||/vertex-/.test(e),Ge=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function De(e){return"createInteractiveEditSession"in e}function Ze(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=c(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function qe(e){const t=e.cursor;return e.cursor="progress",s((()=>e.cursor=t))}async function Be(e,t){const{template:r}=e;if(null==r)return null;if(L(r))return r.load();if(S(r)){const e=F(t,{makeSharedTemplateFromJSON:Qe}),n=await e.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===n.length)throw new o("editor:failed-to-load-template","Unable to load the provided template");return n[0].load()}return r}function Ne(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:i}=t;e.setAttribute(r,n.getAttribute(i))}}const Qe=e=>k.fromJSON(e);export{ze as avoidFeatureTemplateSelectionWithOnlyOneItem,De as canCreateInteractiveEditSession,Ze as cloneGraphicExceptMesh,se as createToolFromGeometryType,Pe as createWorkflowSteps,be as fetchCandidates,Ie as fetchFullFeature,we as findLayerInfo,me as getCreationAttributes,Be as getFullTemplateForCreationInfo,fe as getServiceLayersById,_ as getVisualVariableAttributes,Ee as isTerminalUpdateEventType,$ as isUpdateWorkflow,Re as prepareAttachmentsForCreateFeaturesWorkflow,Ne as setRelationshipFields,Fe as setUpGeometryUpdate,ce as setUpSketchCreateWatchers,Ve as setVisualVariablesAndElevationInfoForUpdate,qe as showProgressCursor,Me as sizeDefaults,Ce as sizeVariableUnitToLengthUnit,le as startCreatingNewFeature,Te as startUpdatingFeatureGeometry,Oe as swapForEditingSession,ae as updateGraphicSymbolWhenRequired,ke as visualVariableInteractiveUpdate,Ge as whenEditorLayerView,xe as whenGraphicDisplayed};
5
+ import e from"../../Color.js";import t from"../../Graphic.js";import{addMany as r,equals as n}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import"../../core/has.js";import o from"../../core/Error.js";import{handlesGroup as a,makeHandle as s,abortHandle as l}from"../../core/handleUtils.js";import{clone as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{whenOrAbort as d,throwIfAborted as f,debounce as y,isPromiseLike as m}from"../../core/promiseUtils.js";import{watch as g,on as h,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as b}from"../../core/screenUtils.js";import{diff as v}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as S,isSharedGroupTemplate as j,isSharedPresetTemplate as I,isStandardFeatureTemplate as T,isSharedFeatureTemplate as V,getAllStandardFeatureTemplatesForLayer as U,isSharedTemplate as L}from"../../editing/templateUtils.js";import k from"../../editing/sharedTemplates/SharedTemplate.js";import{getSharedTemplateProvider as F}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import O from"../../layers/GraphicsLayer.js";import{featureHasFields as A,fixFields as x,getDisplayFieldName as M}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as P}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as C}from"../../renderers/support/lengthUtils.js";import{getTransformationType as R,TransformationType as E}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import G from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import Z from"../../symbols/SimpleMarkerSymbol.js";import{to3D as q}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as B}from"../../symbols/support/symbolUtils.js";import{getServices as N}from"../../undoredo/support/Services.js";import{GraphicState as Q}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as J}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as W}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as H,filterGraphicHits as K}from"../../views/support/hitTestSelectUtils.js";import{isDrawGraphicTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>u.getLogger("esri.widgets.Editor.workflowUtils");function $(e){return"update"===e.type}function _(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!oe(t.renderer))return{rotation:null,size:null};let r=null,n=null;const i=t.renderer.getVisualVariablesForType("rotation").filter((e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression));1===i.length&&(r=ee(i[0],t));const o=t.renderer.getVisualVariablesForType("size").filter((e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&R(e)===E.RealWorldSize));return 1===o.length&&(n=ne(o[0],t)),{rotation:r,size:n}}function ee(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)),o=i&&1===i.length?i[0].type:"double",a={initial:0,current:0};return{field:n,fieldType:o,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(a.current=a.initial-r*e,ie((a.current+360)%360,o)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function te(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 re(e,t,r){if(null==t)return 0;const{symbol:n}=q(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 Math.min(Me.icon,(await e(i,Me.icon))[0])||Me.icon}case"text":return Me.text;case"line":return Me.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return te(await t(i,e.scale/Me.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/Me.viewScaleSizeFactor;default:return 0}}function ne(e,t){const r=e.field,n=e.axis,i=t.fields&&t.fields.filter((e=>e.name===r)),o=i&&1===i.length?i[0].type:"double",a={initial:0,current:0},s=C[e.valueUnit]??1;let l;return l="area"===e.valueRepresentation?e=>(e*s/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*s/2:e=>e*s,{field:r,fieldType:o,getDefaultValue:async(e,t)=>ie(l(await re(t,e,n)),o),getValue:(e,t)=>(a.initial||(a.initial=t.pixelSizeAt(t.center)),a.current=a.initial*e,ie(a.current,o)),setInitialValue:e=>{a.initial=e,a.current=0},isUpdatingInteractively:!1,displayUnit:Ce(e.valueUnit),axis:e.axis}}function ie(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 oe(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 ae(e,t,r){const n=await B(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=v(e.symbol,n)&&(e.symbol=n)}function se(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const n={mode:J,optionsPerTool:r};if(S(t)){const i=t.defaultTool,o=j(t)?t.definition?.inputGeometryType??e:e;switch(i){case"freehand":case"stream-line":return{tool:"polyline"===o?"freehandPolyline":"freehandPolygon",createOptions:n};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:n};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===o?"polygon":"polyline",createOptions:n};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:n};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:n};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:n};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:n};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:n};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:n}}}else{const i=t.drawingTool;if("circle"===i||"ellipse"===i)return r.get("circle").preserveAspectRatio="circle"===i,{tool:"circle",createOptions:n};if("rectangle"===i)return{tool:"rectangle",createOptions:n};if("freehand"===i)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:n}}return{tool:e,createOptions:n}}async function le(e,t,r){const{creationInfo:n,fullTemplate:i}=t;if(!n)throw new o("No creation info provided.");const a=n.layer,s=me(i,n.attributeOverrides),{view:l}=e,c="2d"===l?.type;j(i)||I(i)||await ge(e,a,s,r,c?l.scale:null);const{capabilities:u}=a;e.layer.elevationInfo=a.elevationInfo;const p=se(a.geometryType,i);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:a},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==n.geometryToPlace?await e.create(p.tool):await e.place(n.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:a}})}async function ce(e){return a([await ue(e),await pe(e)])}async function ue({creationAttributes:e,data:t,sketchViewModel:r,view:n,webStyleCache:i}){const{creationInfo:o}=t,{fullTemplate:a}=t;if(!o||"2d"!==n?.type||j(a)||I(a))return null;const s=y((t=>ge(r,o.layer,e,i,t)));return g((()=>n.scale),(e=>s(e)))}async function pe({data:t,sketchViewModel:r,view:n}){const{templateExecutorInfo:i}=t;if(!i)return null;const l=r.activeComponent;if(!n||!X(l))return Y().error(new o("Failed to set up template feedback.")),null;const c=new O({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});n.map?.add(c);const{executor:u,serviceLayersById:p}=i,d=n.theme?.accentColor??new e([255,165,0,1]);return a([h((()=>l),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=l.graphic?.geometry;if(!e||!de(e))return;const t=u(e,"digitizing");if(!m(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=fe(e,d);t&&c.add(t)}}})),s((()=>{n.map.remove(c),c.destroy()}))])}function de(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return n(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function fe(e,r){let n=null;switch(e.geometry?.type){case"point":case"multipoint":n=new Z({angle:0,color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":n=new G({color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":n=new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}async function ye(e,t){const r=await N(t).load(),n=P(e)?e.parent:e,i=r.tablesAndLayersLookup.get(n);if(!i)return new Map;const o=new Map;for(const a of i.layersAndTables)p(o,a.layerId,(()=>[])).push(a);return o}function me(e,t={}){return j(e)||I(e)?{}:T(e)?{...e.prototype.attributes,...t}:V(e)?{...e.definition?.defaultValues,...t}:{...t}}async function ge(e,r,n,i,o){const a=new t({sourceLayer:r,attributes:n}),{rotation:s,size:l}=_(a);let c=await B(a,{useSourceLayer:!0,webStyleCache:i,scale:o}),u=!1;for(const t of[l,s]){if(null==t)continue;null==n[t.field]&&(n[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await B(a,{useSourceLayer:!0,webStyleCache:i,scale:o})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}he(e.tooltipOptions,l,s)}function he(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 we(e,t){return e?.find((e=>e.layer===t))}async function be(e,t,r,n){switch(t.type){case"3d":return ve(e,t,r,n);case"2d":return Se(e,t,r,n)}}async function ve(e,t,n,i){if(0===e.length)return[];const{updatable:o,graphicsByLayer:a}=await n.async((async()=>{const{results:r}=await d(H(t,n),i),o=new Map,a=e=>{const t=e.layer,r=o.get(t);if(!r){const e=new Array;return o.set(t,e),e}return r};K(r).forEach((({graphic:e})=>a(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&o.has(t)));return 0!==s.length&&n.stopPropagation(),{updatable:s,graphicsByLayer:o}}));return d(Promise.allSettled(o.map((async({layer:e})=>{const t=a.get(e),n=je(e);if(t.every((e=>A(n,e))))return t;const o=[];for(const i of t){o.push(i.getObjectId());const e=Object.keys(i.attributes);r(n,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=o,s.outFields=x(e.fieldsIndex,n),e.queryFeatures(s,{signal:i}).then((({features:e})=>e))}))),i)}async function Se(e,t,r,n){if(0===e.length)return[];const{mapPoint:i}=r;if(null==i)return[];let o=null;const a=await r.async((async()=>{const{results:i}=await d(t.hitTest(r),n);if(0===i.length)return[];const a=new Set;o=K(i),o.forEach((({graphic:e})=>e&&a.add(e.layer)));const s=e.filter((e=>a.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return d(Promise.allSettled(a.map((async({layer:e})=>{const a=e.createQuery();a.returnGeometry=!0,a.outFields=je(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;a.geometry=W(i,s,t),a.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(a,{signal:n});return o?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),n)}function je(e){return x(e.fieldsIndex,[e.objectIdField,M({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ie(e,t,r){const{sourceLayer:n}=e,i=n.createQuery();i.objectIds=[e.getAttribute(n.objectIdField)],i.outFields=["*"],i.returnM=n.capabilities.data.supportsM,i.returnZ=n.capabilities.data.supportsZ,"scene"===n.type&&null!=n.infoFor3D||(i.outSpatialReference=t);const o=await n.queryFeatures(i,{signal:r});f(r);return o.features[0]}async function Te(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:i}=e;await Ve(e);const o={multipleSelectionEnabled:!1};return"point"===n.geometryType&&(o.enableRotation=null!=i.rotation,o.enableScaling=null!=i.size),r.update(t,o)}async function Ve(e){const{graphic:t,sketchViewModel:r,sourceLayer:n,visualVariables:i,webStyleCache:o}=e;let a=!1;const{rotation:s,size:l}=i;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),a=!0}}if(a){const e="2d"===r.view?.type?r.view.scale:null;await ae(t,o,e)}he(r.tooltipOptions,l,s),r.layer.elevationInfo=n.elevationInfo}function Ue(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Le(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function ke(e,t,r,n,i){if(null==t.geometry||"point"!==t.geometry?.type)return;const o=n.rotation,a=Ue(r.toolEventInfo);if(null!=o&&null!=a){const{field:r,getValue:n}=o;"rotate-stop"===a.type?(o.isUpdatingInteractively=!1,o.setInitialValue(t.getAttribute(r))):(o.isUpdatingInteractively=!0,t.setAttribute(r,n(a.angle,e)))}const s=n.size,l=Le(r.toolEventInfo);if(null!=s&&null!=l){const{field:r,getValue:n}=s;"scale-stop"===l.type?(s.isUpdatingInteractively=!1,s.setInitialValue(t.getAttribute(r))):(s.isUpdatingInteractively=!0,t.setAttribute(r,n(l.xScale,e)))}await ae(t,i,"2d"===e.type?e.scale:null)}async function Fe({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:n,view:i,onUpdate:o,webStyleCache:c,addUpdatingPromise:u,addHandle:p}){await ae(t,c,"2d"===i.type?i.scale:null);let d=null;if("2d"===n?.view?.type){const e=y((e=>ae(t,c,e)));d=g((()=>n?.view?.scale),(t=>e(t)))}const f=t.sourceLayer,m=Ge(i,f);await Te({graphic:t,sketchViewModel:n,sourceLayer:f,visualVariables:r,webStyleCache:c});let h=null;m.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,S=g((()=>e.attributes),(async e=>{let r=!1;for(const n in e){const i=e[n];i!==t.getAttribute(n)&&(t.setAttribute(n,i),null==b||b.isUpdatingInteractively||b.field!==n||b.setInitialValue(i),null==v||v.isUpdatingInteractively||v.field!==n||v.setInitialValue(i),(null==h||h.requiredFields.includes(n))&&(r=!0))}r&&await ae(t,c,"2d"===i.type?i.scale:null)})),j=n.on("update",(async e=>{const t=e.graphics[0],a={graphic:t,sketchViewModel:n,sourceLayer:f,visualVariables:r,webStyleCache:c};if("complete"===e.state){if(null===i.activeTool)return Te(a);const e=new AbortController,t=l(e);return p(t),u(w((()=>null===i.activeTool),e.signal).then((()=>(e.abort(),Te(a)))))}await ke(i,t,e,r,c),o(Ze(t),e)})),I=n.on(["undo","redo"],(async e=>{o(Ze(e.graphics[0]),e)}));return a([I,j,s((()=>n.cancel())),S,d])}async function Oe(e,t,r){const n=e.view;e.layer.add(r);const o=t.sourceLayer,l=t.layer,c=t.getAttribute(l.objectIdField);let u=null;function p(e){u?.abort(),u=i((async t=>{const r=await Ge(n,o);f(t),r.setVisibility?.(c,e)}))}return await xe(n,r),p(!1),a([Ae(n,r,(e=>p(!e))),s((async()=>{p(!0);try{const e=await Ge(n,o);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function Ae(e,t,r){if("3d"===e.type){const n=new Q({graphic:t});return a([e.trackGraphicState(n),g((()=>n.displaying),r)])}return g((()=>t.visible),r)}async function xe(e,t){if("3d"===e.type){const r=new Q({graphic:t}),n=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),n.remove()}else await w((()=>t.visible))}const Me={icon:b(24),text:b(12),line:b(1),viewScaleSizeFactor:100};function Pe(e,t,r){let n=!1;return e.filter((e=>!!n||(n=e===t,n))).map((e=>r[e]()))}function ze(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,n=U(e);1===n.length&&"scene"!==e.type&&(r.template=n[0],t.shift())}return t}function Ce(e){return"unknown"===e?null:e}function Re(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const Ee=e=>/-stop/.test(e)||/vertex-/.test(e),Ge=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function De(e){return"createInteractiveEditSession"in e}function Ze(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=c(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function qe(e){const t=e.cursor;return e.cursor="progress",s((()=>e.cursor=t))}async function Be(e,t){const{template:r}=e;if(null==r)return null;if(L(r))return r.load();if(S(r)){const e=F(t,{makeSharedTemplateFromJSON:Qe}),n=await e.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===n.length)throw new o("editor:failed-to-load-template","Unable to load the provided template");return n[0].load()}return r}function Ne(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:n,sourceField:i}=t;e.setAttribute(r,n.getAttribute(i))}}const Qe=e=>k.fromJSON(e);export{ze as avoidFeatureTemplateSelectionWithOnlyOneItem,De as canCreateInteractiveEditSession,Ze as cloneGraphicExceptMesh,se as createToolFromGeometryType,Pe as createWorkflowSteps,be as fetchCandidates,Ie as fetchFullFeature,we as findLayerInfo,me as getCreationAttributes,Be as getFullTemplateForCreationInfo,ye as getServiceLayersById,_ as getVisualVariableAttributes,Ee as isTerminalUpdateEventType,$ as isUpdateWorkflow,Re as prepareAttachmentsForCreateFeaturesWorkflow,Ne as setRelationshipFields,Fe as setUpGeometryUpdate,ce as setUpSketchCreateWatchers,Ve as setVisualVariablesAndElevationInfoForUpdate,qe as showProgressCursor,Me as sizeDefaults,Ce as sizeVariableUnitToLengthUnit,le as startCreatingNewFeature,Te as startUpdatingFeatureGeometry,Oe as swapForEditingSession,ae as updateGraphicSymbolWhenRequired,ke as visualVariableInteractiveUpdate,Ge as whenEditorLayerView,xe as whenGraphicDisplayed};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import l from"../../../core/Clonable.js";import a from"../../../core/Collection.js";import s from"../../../core/Identifiable.js";import{ignoreAbortErrors as i,debounce as n}from"../../../core/promiseUtils.js";import{watch as u,initial as d}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as y}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as c,findRelatedLayer as C}from"../support/featureUtils.js";import{getFieldsInTitleAndDesc as b}from"../../FeatureForm/featureFormUtils.js";const g=100;let _=class extends(l.ClonableMixin(s.IdentifiableMixin(r))){constructor(e){super(e),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await i(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await i(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await i(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=n(this._queryController,g),this._queryFeatureCountDebounced=n(this._queryFeatureCountController,g),this._queryPageDebounced=n(this._queryPageController,g),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this.featureCount&&(this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.destroyAll(),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal}))))},this.addHandles([u((()=>[this.displayCount,this.graphic,this.layer,this.layer?.loaded,this.map,this.orderByFields,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount]),(()=>this._queryDebounced()),d),u((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageDebounced())),u((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery]),(()=>this._queryFeatureCountDebounced()))])}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.destroyAll(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=c(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canLoad(){return!!this.map&&null!=this.relationshipId&&"number"==typeof this.objectId}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&null!=this.relationshipId&&null!=this.objectId&&e?.supportsCount&&e?.supportsPagination)}get itemDescriptionFieldName(){return this.orderByFieldsFixedCasing[0]?.field||null}set displayCount(e){const t=0,r=10,o=3;this._set("displayCount",Math.min(Math.max(e??o,t),r))}get displayCount(){return this._get("displayCount")}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get relatedFeatures(){return this._get("relatedFeatures")||new a}get relatedLayer(){const{layer:e,map:t,relationship:r}=this;return e?.loaded&&t&&r?C(t,e,r)??null:null}get relationship(){const{relationshipId:e,layer:t}=this;return null!=e?t?.relationships?.find((({id:t})=>t===e))??null:null}get relatedFeatureViewModels(){return this._get("relatedFeatureViewModels")||new a}get state(){const{_queryAbortController:e,_queryFeatureCountAbortController:t,_queryPageAbortController:r,canQuery:o,_loaded:l,canLoad:a}=this;return t||a&&!l?"loading":e||r?"querying":o?"ready":"disabled"}getRelatedFeatureByObjectId(e){return this.relatedFeatures.find((t=>t.getObjectId()===e))}refresh(){this._queryFeatureCountDebounced()}_destroyRelatedFeatureViewModels(){this.relatedFeatureViewModels?.destroyAll()}async _queryFeatureCount(){const{layer:e,relatedLayer:t,relationshipId:r,objectId:o,_queryFeatureCountAbortController:l,canQuery:a,supportsCacheHint:s}=this;if(await(e?.load()),await(t?.load()),!a||!e||!t||null==o)return void this._set("featureCount",0);const i=t.createQuery(),{historicMoment:n,gdbVersion:u}=e,d=new p({cacheHint:s,gdbVersion:u,historicMoment:n,relationshipId:r,returnGeometry:!1,objectIds:[o],where:i.where??void 0}),h=await e.queryRelatedFeaturesCount(d,{signal:l?.signal});this._set("featureCount",h[o]||0)}_sliceFeatures(e){const{showAllEnabled:t,displayCount:r}=this;return t?e:r?e.slice(0,r):[]}async _queryPage(){const{relatedFeatures:e,featurePage:t,showAllEnabled:r,_queryPageAbortController:o,featureCount:l}=this;!r||t<2||!l||e.addMany(await this._queryRelatedFeatures({signal:o?.signal}))}async _queryRelatedFeatures(e){const{orderByFieldsFixedCasing:t,showAllEnabled:r,featuresPerPage:l,displayCount:a,layer:s,relationshipId:i,featurePage:n,featureCount:u,relatedLayer:d,supportsCacheHint:h}=this,{canQuery:y,objectId:c}=this;if(!y||!s||!d||null==c)return[];const C=r?((n-1)*l+u)%u:0,g=r?l:a,_=d.objectIdField,F=[...t.map((e=>e.field)),...b(d),_].filter(o),m=t.map((e=>`${e.field} ${e.order}`)),f=d.createQuery(),{historicMoment:q,gdbVersion:A}=s,P=new p({orderByFields:m,start:C,num:g,outFields:F,cacheHint:h,historicMoment:q,gdbVersion:A,relationshipId:i,returnGeometry:!1,objectIds:[c],where:f.where??void 0}),w=await s.queryRelatedFeatures(P,{signal:e?.signal}),j=w[c]?.features||[];return j.forEach((e=>{e.sourceLayer=d,e.layer=d})),j}};e([h()],_.prototype,"_loaded",void 0),e([h()],_.prototype,"_queryAbortController",void 0),e([h()],_.prototype,"_queryPageAbortController",void 0),e([h()],_.prototype,"_queryFeatureCountAbortController",void 0),e([h({value:1})],_.prototype,"featurePage",null),e([h()],_.prototype,"featuresPerPage",void 0),e([h({readOnly:!0})],_.prototype,"orderByFieldsFixedCasing",null),e([h({readOnly:!0})],_.prototype,"supportsCacheHint",null),e([h({readOnly:!0})],_.prototype,"canLoad",null),e([h({readOnly:!0})],_.prototype,"canQuery",null),e([h()],_.prototype,"description",void 0),e([h({readOnly:!0})],_.prototype,"itemDescriptionFieldName",null),e([h({value:3})],_.prototype,"displayCount",null),e([h({type:t})],_.prototype,"graphic",void 0),e([h()],_.prototype,"layer",void 0),e([h()],_.prototype,"map",void 0),e([h({readOnly:!0})],_.prototype,"objectId",null),e([h({readOnly:!0})],_.prototype,"objectIdField",null),e([h()],_.prototype,"orderByFields",void 0),e([h({readOnly:!0})],_.prototype,"relatedFeatures",null),e([h({readOnly:!0})],_.prototype,"relatedLayer",null),e([h({readOnly:!0})],_.prototype,"relationship",null),e([h()],_.prototype,"featureCount",void 0),e([h({readOnly:!0})],_.prototype,"relatedFeatureViewModels",null),e([h()],_.prototype,"relationshipId",void 0),e([h()],_.prototype,"showAllEnabled",void 0),e([h()],_.prototype,"state",null),e([h()],_.prototype,"title",void 0),_=e([y("esri.widgets.Feature.FeatureRelationship.FeatureRelationshipViewModel")],_);const F=_;export{F as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import l from"../../../core/Clonable.js";import i from"../../../core/Collection.js";import a from"../../../core/Identifiable.js";import{ignoreAbortErrors as s,debounce as n}from"../../../core/promiseUtils.js";import{watch as u,initial as d}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as c,isRelatableFeatureSupportedLayer as g,findRelatedLayer as C}from"../support/featureUtils.js";import{getFieldsInTitleAndDesc as b}from"../../FeatureForm/featureFormUtils.js";const F=100;let _=class extends(l.ClonableMixin(a.IdentifiableMixin(r))){constructor(e){super(e),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.activeCategory=null,this.categories=null,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await s(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await s(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await s(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=n(this._queryController,F),this._queryFeatureCountDebounced=n(this._queryFeatureCountController,F),this._queryPageDebounced=n(this._queryPageController,F),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this.featureCount&&("subtype-group"!==this.relatedLayer?.type||this.activeCategory)&&(this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.destroyAll(),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal}))))},this.addHandles([u((()=>[this.displayCount,this.graphic,this.layer,this.layer?.loaded,this.map,this.orderByFields,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount,this.activeCategory]),(()=>this._queryDebounced()),d),u((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageDebounced())),u((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery,this.activeCategory]),(()=>this._queryFeatureCountDebounced()))])}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.destroyAll(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=c(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canLoad(){return!!this.map&&null!=this.relationshipId&&"number"==typeof this.objectId}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&null!=this.relationshipId&&null!=this.objectId&&e?.supportsCount&&e?.supportsPagination)}set displayCount(e){const t=0,r=10,o=3;this._set("displayCount",Math.min(Math.max(e??o,t),r))}get displayCount(){return this._get("displayCount")}get itemDescriptionFieldName(){return this.orderByFieldsFixedCasing[0]?.field||null}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get relatedFeatures(){return this._get("relatedFeatures")||new i}get relatedLayer(){const{layer:e,map:t,relationship:r}=this;if(!e?.loaded||!t||!r)return null;const o="subtype-sublayer"===e.type&&e.parent&&g(e.parent)?e.parent:e;return C(t,o,r)??null}get relatedLayerKeyField(){const{relatedLayer:e,relationshipId:t}=this;return e?.loaded&&null!=t?e.relationships?.find((e=>e.id===t))?.keyField:null}get relatedLayerKeyFields(){const{relatedLayer:e}=this;return e?.loaded?e.relationships?.map((e=>e.keyField)).filter(o)??[]:[]}get relationship(){const{relationshipId:e,layer:t}=this;return null!=e&&t?.loaded?t.relationships?.find((({id:t})=>t===e))??null:null}get relationshipKey(){const{relationshipKeyField:e}=this;return(e&&this.graphic?.attributes?.[e])??null}get relationshipKeyField(){return this.relationship?.keyField||null}get relatedFeatureViewModels(){return this._get("relatedFeatureViewModels")||new i}get state(){const{_queryAbortController:e,_queryFeatureCountAbortController:t,_queryPageAbortController:r,canQuery:o,_loaded:l,canLoad:i}=this;return t||i&&!l?"loading":e||r?"querying":o?"ready":"disabled"}getRelatedFeatureByObjectId(e){return this.relatedFeatures.find((t=>t.getObjectId()===e))}refresh(){this._queryFeatureCountDebounced()}_destroyRelatedFeatureViewModels(){this.relatedFeatureViewModels?.destroyAll()}async _queryFeatureCount(){const{layer:e,relatedLayer:t}=this;await(e?.load()),await(t?.load());const{_queryFeatureCountAbortController:r,activeCategory:l,canQuery:i,displayCount:a,objectId:s,relatedLayerKeyField:n,relationshipId:u,relationshipKey:d,showAllEnabled:y,supportsCacheHint:h}=this;if(!i||!e||!t||null==s)return this._set("featureCount",0),void this._set("categories",null);if("subtype-group"===t?.type&&!l){if(this._set("featureCount",0),this._destroyRelatedFeatureViewModels(),this.featurePage=1,this.relatedFeatures.destroyAll(),n&&null!=d){const{default:e}=await import("../../../smartMapping/statistics/uniqueValues.js"),{uniqueValueInfos:l}=await e({layer:t,sqlWhere:`${n} = '${d}'`,field:t.subtypeField,signal:r?.signal}),i=l.map((({count:e,value:r})=>{const o=t.subtypes?.find((e=>e.code===r))?.name;return null!=r&&o?{count:e,value:r,name:o}:void 0})).filter(o);this._set("categories",y?i:i.slice(0,a))}return}const{historicMoment:c,gdbVersion:g}=e,C=new p({cacheHint:h,gdbVersion:g,historicMoment:c,relationshipId:u,returnGeometry:!1,objectIds:[s],where:this._getRelationshipWhereClause(t)}),b=await e.queryRelatedFeaturesCount(C,{signal:r?.signal});this._set("categories",null),this._set("featureCount",b[s]||0)}_getRelationshipWhereClause(e){const{activeCategory:t}=this,r=e.createQuery(),o="subtypeField"in e?e.subtypeField:void 0,l=t&&o?`${o} = ${t.value}`:void 0,i=r.where;return i&&l?`(${i}) AND (${l})`:i??l}_sliceFeatures(e){const{showAllEnabled:t,displayCount:r}=this;return t?e:r?e.slice(0,r):[]}async _queryPage(){const{relatedFeatures:e,featurePage:t,showAllEnabled:r,_queryPageAbortController:o,featureCount:l}=this;!r||t<2||!l||"subtype-group"===this.relatedLayer?.type&&!this.activeCategory||e.addMany(await this._queryRelatedFeatures({signal:o?.signal}))}async _queryRelatedFeatures(e){const{displayCount:t,featureCount:r,featurePage:l,featuresPerPage:i,layer:a,orderByFieldsFixedCasing:s,relatedLayer:n,relatedLayerKeyFields:u,relationshipId:d,showAllEnabled:y,supportsCacheHint:h}=this,{canQuery:c,objectId:g}=this;if(!c||!a||!n||null==g)return[];const C=y?((l-1)*i+r)%r:0,F=y?i:t,_=n.objectIdField,f="subtypeField"in n?n.subtypeField:void 0,m=[...s.map((e=>e.field)),...b(n),...u,_,f].filter(o),q=s.map((e=>`${e.field} ${e.order}`)),{historicMoment:A,gdbVersion:w}=a,P=new p({orderByFields:q,start:C,num:F,outFields:m,cacheHint:h,historicMoment:A,gdbVersion:w,relationshipId:d,returnGeometry:!1,objectIds:[g],where:this._getRelationshipWhereClause(n)}),v=await a.queryRelatedFeatures(P,{signal:e?.signal}),j=v[g]?.features||[];return"subtype-group"===n.type&&f?j.forEach((e=>{const t=e.attributes[f],r=n.findSublayerForSubtypeCode?.(t);e.sourceLayer=r,e.layer=r})):j.forEach((e=>{e.sourceLayer=n,e.layer=n})),j}};e([y()],_.prototype,"_loaded",void 0),e([y()],_.prototype,"_queryAbortController",void 0),e([y()],_.prototype,"_queryPageAbortController",void 0),e([y()],_.prototype,"_queryFeatureCountAbortController",void 0),e([y({value:1})],_.prototype,"featurePage",null),e([y()],_.prototype,"featuresPerPage",void 0),e([y({readOnly:!0})],_.prototype,"orderByFieldsFixedCasing",null),e([y({readOnly:!0})],_.prototype,"supportsCacheHint",null),e([y({readOnly:!0})],_.prototype,"canLoad",null),e([y({readOnly:!0})],_.prototype,"canQuery",null),e([y()],_.prototype,"activeCategory",void 0),e([y({readOnly:!0})],_.prototype,"categories",void 0),e([y()],_.prototype,"description",void 0),e([y({value:3})],_.prototype,"displayCount",null),e([y({type:t})],_.prototype,"graphic",void 0),e([y({readOnly:!0})],_.prototype,"itemDescriptionFieldName",null),e([y()],_.prototype,"layer",void 0),e([y()],_.prototype,"map",void 0),e([y({readOnly:!0})],_.prototype,"objectId",null),e([y({readOnly:!0})],_.prototype,"objectIdField",null),e([y()],_.prototype,"orderByFields",void 0),e([y({readOnly:!0})],_.prototype,"relatedFeatures",null),e([y({readOnly:!0})],_.prototype,"relatedLayer",null),e([y({readOnly:!0})],_.prototype,"relatedLayerKeyField",null),e([y({readOnly:!0})],_.prototype,"relatedLayerKeyFields",null),e([y({readOnly:!0})],_.prototype,"relationship",null),e([y({readOnly:!0})],_.prototype,"relationshipKey",null),e([y({readOnly:!0})],_.prototype,"relationshipKeyField",null),e([y({readOnly:!0})],_.prototype,"featureCount",void 0),e([y({readOnly:!0})],_.prototype,"relatedFeatureViewModels",null),e([y()],_.prototype,"relationshipId",void 0),e([y()],_.prototype,"showAllEnabled",void 0),e([y()],_.prototype,"state",null),e([y()],_.prototype,"title",void 0),_=e([h("esri.widgets.Feature.FeatureRelationship.FeatureRelationshipViewModel")],_);const f=_;export{f 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{destroyMaybe as t}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{watch as i,initial as r,on as o}from"../../core/reactiveUtils.js";import{stripHTML as n}from"../../core/string.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import{cast as a}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import c from"../Widget.js";import u from"./FeatureRelationship/FeatureRelationshipViewModel.js";import h from"./support/FeatureElementInfo.js";import{loadCalciteComponents as p}from"../support/componentsUtils.js";import{globalCss as m}from"../support/globalCss.js";import{isRTL as v}from"../support/widgetUtils.js";import{messageBundle as w}from"../support/decorators/messageBundle.js";import{tsx as f}from"../support/jsxFactory.js";import{substitute as _}from"../../intl/substitute.js";var b;const g="esri-feature",y=`${g}-relationship`,F={base:y,listContainer:`${y}__list`,listItem:`${y}__list-item`,listItemHidden:`${y}__list-item--hidden`,listContainerQuerying:`${y}__list--querying`,featureObserver:`${g}__feature-observer`,stickySpinnerContainer:`${g}__sticky-loading-container`,loadingSpinnerContainer:`${g}__loading-container`},I={title:!0,description:!0};let M=b=class extends c{constructor(e,t){super(e,t),this._featureElementInfo=null,this._relatedFeatureIntersectionObserverNode=null,this._relatedFeatureIntersectionObserver=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this.flowItems=null,this.flowType="feature-relationship",this.headingLevel=2,this.viewModel=new u,this.messages=null,this.messagesCommon=null,this.visibleElements={...I},this._increaseFeaturePage=()=>{const{state:e,showAllEnabled:t,relatedFeatures:s,featuresPerPage:i,featurePage:r}=this.viewModel;"ready"===e&&t&&s.length>=i*r&&this.viewModel.featurePage++}}initialize(){this._featureElementInfo=new h,this.addHandles([i((()=>[this.viewModel.description,this.viewModel.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),r),i((()=>[this.viewModel.state,this.viewModel.showAllEnabled,this._relatedFeatureIntersectionObserverNode]),(()=>this._handleRelatedFeatureObserverChange())),o((()=>this.viewModel.relatedFeatureViewModels),"change",(()=>this._setupRelatedFeatureViewModels()))])}loadDependencies(){return p({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._unobserveRelatedFeatureObserver(),this._featureElementInfo=t(this._featureElementInfo)}get displayShowAllButton(){const{showAllEnabled:e,featureCount:t,displayCount:s,state:i}=this.viewModel;return!e&&!!t&&"ready"===i&&(t>s||0===s)}get displayListItems(){return this.displayShowAllButton||this.viewModel.relatedFeatureViewModels.length>0}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get featureCountDescription(){const{messages:e}=this,{featureCount:t}=this.viewModel;return _(e?.numberRecords,{number:t})}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}castVisibleElements(e){return{...I,...e}}render(){const{state:e}=this.viewModel;return f("div",{class:this.classes(F.base,m.widget)},this._featureElementInfo?.render(),"loading"===e?this._renderLoading():"disabled"===e?this._renderRelationshipNotFound():this._renderRelatedFeatures())}async _selectRecord(e){const{flowItems:t,featureVisibleElements:s}=this;if(!t)return;e.abilities={relationshipContent:!0};const{default:i}=await import("../Feature.js");t.push(new i({flowItems:t,flowType:this.flowType,viewModel:e,visibleElements:s}))}_showAllRecords(){const{flowItems:e}=this;if(!e)return;const{viewModel:t,featureVisibleElements:s}=this;t.showAllEnabled=!0;const i=new b({flowItems:e,featureVisibleElements:s,visibleElements:{title:!1,description:!1},viewModel:t});e.push(i)}_renderStickyLoading(){return"querying"===this.viewModel.state?f("div",{class:F.stickySpinnerContainer,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoadingIcon(){return f("calcite-loader",{inline:!0,label:""})}_renderLoading(){return f("div",{class:F.loadingSpinnerContainer,key:"loading-container"},this._renderLoadingIcon())}_renderShowAllIconNode(){return f("calcite-icon",{icon:"list",scale:"s",slot:"content-end"})}_renderChevronIconNode(){const e=v(this.container)?"chevron-left":"chevron-right";return f("calcite-icon",{icon:e,scale:"s",slot:"content-end"})}_renderRelatedFeature(e){const{itemDescriptionFieldName:t}=this.viewModel,s=e.title;e.description=t&&e.formattedAttributes?.global[t];const i="loading"===e.state;return f("calcite-list-item",{class:this.classes(F.listItem,{[F.listItemHidden]:i}),description:n(e.description??""),key:e.uid,label:n(s),onCalciteListItemSelect:()=>this._selectRecord(e)},this._renderChevronIconNode())}_renderShowAllListItem(){return this.displayShowAllButton?f("calcite-list-item",{description:this.featureCountDescription,key:"show-all-item",label:this.messages?.showAll,onCalciteListItemSelect:()=>this._showAllRecords()},this._renderShowAllIconNode()):null}_renderNoRelatedFeaturesMessage(){return f("calcite-notice",{icon:"information",key:"no-related-features-message",kind:"brand",open:!0,scale:"s",width:"full"},f("div",{slot:"message"},this.messages?.noRelatedFeatures))}_renderFeatureObserver(){return f("div",{afterCreate:this._relatedFeatureIntersectionObserverCreated,bind:this,class:F.featureObserver,key:"feature-observer"})}_renderList(){const{relatedFeatureViewModels:e}=this.viewModel;return f("calcite-list",{displayMode:"flat",label:this.messages?.relatedFeaturesList},e.toArray().map((e=>this._renderRelatedFeature(e))),this._renderShowAllListItem())}_renderRelatedFeatures(){const{displayListItems:e}=this,{state:t}=this.viewModel;return f("div",{class:this.classes(F.listContainer,{[F.listContainerQuerying]:"querying"===t}),key:"list-container"},e?this._renderList():"ready"===t?this._renderNoRelatedFeaturesMessage():null,this._renderStickyLoading(),this._renderFeatureObserver())}_renderRelationshipNotFound(){return f("calcite-notice",{icon:"exclamation-mark-triangle",key:"relationship-not-found",kind:"danger",open:!0,scale:"s",width:"full"},f("div",{slot:"message"},this.messages?.relationshipNotFound))}_setupRelatedFeatureViewModels(){const{relatedFeatureViewModels:e}=this.viewModel,t="related-feature-viewmodels";this.removeHandles(t),e?.forEach((e=>{this.addHandles(i((()=>[e.title,e.state]),(()=>this.scheduleRender()),r),t)})),this.scheduleRender()}_setupFeatureElementInfo(){const{headingLevel:e,visibleElements:t}=this,s=t.description&&this.description,i=t.title&&this.title;this._featureElementInfo?.set({description:s,title:i,headingLevel:e})}async _handleRelatedFeatureObserverChange(){this._unobserveRelatedFeatureObserver();const{state:e,showAllEnabled:t}=this.viewModel;await s(0),this._relatedFeatureIntersectionObserverNode&&"ready"===e&&t&&this._relatedFeatureIntersectionObserver.observe(this._relatedFeatureIntersectionObserverNode)}_relatedFeatureIntersectionObserverCreated(e){this._relatedFeatureIntersectionObserverNode=e}_unobserveRelatedFeatureObserver(){this._relatedFeatureIntersectionObserverNode&&this._relatedFeatureIntersectionObserver.unobserve(this._relatedFeatureIntersectionObserverNode)}};e([l()],M.prototype,"_relatedFeatureIntersectionObserverNode",void 0),e([l({readOnly:!0})],M.prototype,"displayShowAllButton",null),e([l({readOnly:!0})],M.prototype,"displayListItems",null),e([l()],M.prototype,"description",null),e([l({readOnly:!0})],M.prototype,"featureCountDescription",null),e([l()],M.prototype,"featureVisibleElements",void 0),e([l()],M.prototype,"flowItems",void 0),e([l()],M.prototype,"flowType",void 0),e([l()],M.prototype,"headingLevel",void 0),e([l()],M.prototype,"title",null),e([l({type:u})],M.prototype,"viewModel",void 0),e([l(),w("esri/widgets/Feature/t9n/Feature")],M.prototype,"messages",void 0),e([l(),w("esri/t9n/common")],M.prototype,"messagesCommon",void 0),e([l()],M.prototype,"visibleElements",void 0),e([a("visibleElements")],M.prototype,"castVisibleElements",null),M=b=e([d("esri.widgets.Feature.FeatureRelationship")],M);const C=M;export{C as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{destroyMaybe as t}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{watch as i,initial as r,on as o}from"../../core/reactiveUtils.js";import{stripHTML as n}from"../../core/string.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import{cast as a}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import c from"../Widget.js";import u from"./FeatureRelationship/FeatureRelationshipViewModel.js";import h from"./support/FeatureElementInfo.js";import{loadCalciteComponents as p}from"../support/componentsUtils.js";import{globalCss as m}from"../support/globalCss.js";import{isRTL as v}from"../support/widgetUtils.js";import{messageBundle as w}from"../support/decorators/messageBundle.js";import{tsx as g}from"../support/jsxFactory.js";import{substitute as _}from"../../intl/substitute.js";import{formatNumber as f}from"../../intl/number.js";var b;const y="esri-feature",I=`${y}-relationship`,F={base:I,listContainer:`${I}__list`,listItem:`${I}__list-item`,listItemHidden:`${I}__list-item--hidden`,listContainerQuerying:`${I}__list--querying`,featureObserver:`${y}__feature-observer`,stickySpinnerContainer:`${y}__sticky-loading-container`,loadingSpinnerContainer:`${y}__loading-container`},M={title:!0,description:!0};let C=b=class extends c{constructor(e,t){super(e,t),this._featureElementInfo=null,this._relatedFeatureIntersectionObserverNode=null,this._relatedFeatureIntersectionObserver=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this.flowItems=null,this.flowType="feature-relationship",this.headingLevel=2,this.viewModel=new u,this.messages=null,this.messagesCommon=null,this.visibleElements={...M},this._increaseFeaturePage=()=>{const{state:e,showAllEnabled:t,relatedFeatures:s,featuresPerPage:i,featurePage:r}=this.viewModel;"ready"===e&&t&&s.length>=i*r&&this.viewModel.featurePage++}}initialize(){this._featureElementInfo=new h,this.addHandles([i((()=>[this.viewModel.description,this.viewModel.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),r),i((()=>[this.viewModel.state,this.viewModel.showAllEnabled,this._relatedFeatureIntersectionObserverNode]),(()=>this._handleRelatedFeatureObserverChange())),o((()=>this.viewModel.relatedFeatureViewModels),"change",(()=>this._setupRelatedFeatureViewModels()))])}loadDependencies(){return p({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._unobserveRelatedFeatureObserver(),this._featureElementInfo=t(this._featureElementInfo)}get displayShowAllButton(){const{showAllEnabled:e,featureCount:t,displayCount:s,state:i,categories:r}=this.viewModel;return!e&&"ready"===i&&((r?.length??0)>s||0===s||!!t&&(t>s||0===s))}get displayListItems(){const{relatedFeatureViewModels:e,categories:t}=this.viewModel;return this.displayShowAllButton||!!e.length||!!t?.length}get allItemsDescription(){const{messages:e}=this,{featureCount:t,categories:s}=this.viewModel;return _(e?.numberRecords,{number:f(s?.length??t)})}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get title(){const{activeCategory:e,title:t}=this.viewModel;return e?.name??t}set title(e){this.viewModel.title=e}castVisibleElements(e){return{...M,...e}}render(){const{state:e}=this.viewModel;return g("div",{class:this.classes(F.base,m.widget)},this._featureElementInfo?.render(),"loading"===e?this._renderLoading():"disabled"===e?this._renderRelationshipNotFound():this._renderRelatedFeatures())}async _selectCategory(e){const{flowItems:t,featureVisibleElements:s,viewModel:i}=this;t&&(i.activeCategory=e,i.showAllEnabled=!0,t.push(new b({flowItems:t,featureVisibleElements:s,visibleElements:{title:!1,description:!1},viewModel:i})))}async _selectRecord(e){const{flowItems:t,featureVisibleElements:s}=this;if(!t)return;e.abilities={relationshipContent:!0};const{default:i}=await import("../Feature.js");t.push(new i({flowItems:t,flowType:this.flowType,viewModel:e,visibleElements:s}))}_showAllRecords(){const{flowItems:e}=this;if(!e)return;const{viewModel:t,featureVisibleElements:s}=this;t.showAllEnabled=!0;const i=new b({flowItems:e,featureVisibleElements:s,visibleElements:{title:!1,description:!1},viewModel:t});e.push(i)}_renderStickyLoading(){return"querying"===this.viewModel.state?g("div",{class:F.stickySpinnerContainer,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoadingIcon(){return g("calcite-loader",{inline:!0,label:""})}_renderLoading(){return g("div",{class:F.loadingSpinnerContainer,key:"loading-container"},this._renderLoadingIcon())}_renderShowAllIconNode(){return g("calcite-icon",{icon:"list",scale:"s",slot:"content-end"})}_renderChevronIconNode(){const e=v(this.container)?"chevron-left":"chevron-right";return g("calcite-icon",{icon:e,scale:"s",slot:"content-end"})}_renderCategory(e){const{count:t,name:s,value:i}=e,r=f(t);return g("calcite-list-item",{class:F.listItem,disabled:!t,key:i,label:s,onCalciteListItemSelect:()=>this._selectCategory(e)},g("calcite-chip",{label:r,scale:"s",slot:"content-end"},r),this._renderChevronIconNode())}_renderRelatedFeature(e){const{itemDescriptionFieldName:t}=this.viewModel,s=e.title;e.description=t&&e.formattedAttributes?.global[t];const i="loading"===e.state;return g("calcite-list-item",{class:this.classes(F.listItem,{[F.listItemHidden]:i}),description:n(e.description??""),key:e.uid,label:n(s),onCalciteListItemSelect:()=>this._selectRecord(e)},this._renderChevronIconNode())}_renderShowAllListItem(){return this.displayShowAllButton?g("calcite-list-item",{description:this.allItemsDescription,key:"show-all-item",label:this.messages?.showAll,onCalciteListItemSelect:()=>this._showAllRecords()},this._renderShowAllIconNode()):null}_renderNoRelatedFeaturesMessage(){return g("calcite-notice",{icon:"information",key:"no-related-features-message",kind:"brand",open:!0,scale:"s",width:"full"},g("div",{slot:"message"},this.messages?.noRelatedFeatures))}_renderFeatureObserver(){return g("div",{afterCreate:this._relatedFeatureIntersectionObserverCreated,bind:this,class:F.featureObserver,key:"feature-observer"})}_renderList(){const{relatedFeatureViewModels:e,categories:t}=this.viewModel;return g("calcite-list",{displayMode:"flat",label:this.messages?.relatedFeaturesList},t?.map((e=>this._renderCategory(e)))??e.toArray().map((e=>this._renderRelatedFeature(e))),this._renderShowAllListItem())}_renderRelatedFeatures(){const{displayListItems:e}=this,{state:t}=this.viewModel;return g("div",{class:this.classes(F.listContainer,{[F.listContainerQuerying]:"querying"===t}),key:"list-container"},e?this._renderList():"ready"===t?this._renderNoRelatedFeaturesMessage():null,this._renderStickyLoading(),this._renderFeatureObserver())}_renderRelationshipNotFound(){return g("calcite-notice",{icon:"exclamation-mark-triangle",key:"relationship-not-found",kind:"danger",open:!0,scale:"s",width:"full"},g("div",{slot:"message"},this.messages?.relationshipNotFound))}_setupRelatedFeatureViewModels(){const{relatedFeatureViewModels:e}=this.viewModel,t="related-feature-viewmodels";this.removeHandles(t),e?.forEach((e=>{this.addHandles(i((()=>[e.title,e.state]),(()=>this.scheduleRender()),r),t)})),this.scheduleRender()}_setupFeatureElementInfo(){const{headingLevel:e,visibleElements:t}=this,s=t.description&&this.description,i=t.title&&this.title;this._featureElementInfo?.set({description:s,title:i,headingLevel:e})}async _handleRelatedFeatureObserverChange(){this._unobserveRelatedFeatureObserver();const{state:e,showAllEnabled:t}=this.viewModel;await s(0),this._relatedFeatureIntersectionObserverNode&&"ready"===e&&t&&this._relatedFeatureIntersectionObserver.observe(this._relatedFeatureIntersectionObserverNode)}_relatedFeatureIntersectionObserverCreated(e){this._relatedFeatureIntersectionObserverNode=e}_unobserveRelatedFeatureObserver(){this._relatedFeatureIntersectionObserverNode&&this._relatedFeatureIntersectionObserver.unobserve(this._relatedFeatureIntersectionObserverNode)}};e([l()],C.prototype,"_relatedFeatureIntersectionObserverNode",void 0),e([l({readOnly:!0})],C.prototype,"displayShowAllButton",null),e([l({readOnly:!0})],C.prototype,"displayListItems",null),e([l({readOnly:!0})],C.prototype,"allItemsDescription",null),e([l()],C.prototype,"description",null),e([l()],C.prototype,"featureVisibleElements",void 0),e([l()],C.prototype,"flowItems",void 0),e([l()],C.prototype,"flowType",void 0),e([l()],C.prototype,"headingLevel",void 0),e([l()],C.prototype,"title",null),e([l({type:u})],C.prototype,"viewModel",void 0),e([l(),w("esri/widgets/Feature/t9n/Feature")],C.prototype,"messages",void 0),e([l(),w("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([l()],C.prototype,"visibleElements",void 0),e([a("visibleElements")],C.prototype,"castVisibleElements",null),C=b=e([d("esri.widgets.Feature.FeatureRelationship")],C);const E=C;export{E 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{stripHTML as t}from"../../core/string.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{getFeaturePopupTitle as o}from"../../support/popupUtils.js";import l from"./FeatureUtilityNetworkAssociations/VisibleElements.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import{globalCss as n}from"../support/globalCss.js";import"../support/widgetUtils.js";import{tsx as a,tsxFragment as c}from"../support/jsxFactory.js";import d from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import p from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{formatPercentAlong as u}from"../support/UtilityNetworkAssociations/utils/formatPercentAlong.js";import{isConnectivity as m}from"../support/UtilityNetworkAssociations/utils/isConnectivity.js";import{isConnectivityMidspan as h}from"../support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js";import{substitute as w}from"../../intl/substitute.js";var f;const y="esri-feature-utility-network-associations",b={base:y,listItemHidden:`${y}__list-item--hidden`},v="nested";let g=f=class extends p{constructor(e,t){super(e,t),this.description=null,this.flowItems=null,this.flowType="feature-utility-network-association-type",this.listType=null,this.parentFeatureViewModel=null,this.title=null,this.viewModel=new d,this.visibleElements=new l}initialize(){this.setUpObserver()}loadDependencies(){return r({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this.tooltipReferenceMap.clear()}render(){const e=this.viewModel.associationViewModels,{state:t,showAllEnabled:i}=this.viewModel,{state:s}=this.parentFeatureViewModel??{};return a("div",{class:this.classes(b.base,n.widget)},"loading"===t||"querying"===t||"loading"===s?this.renderLoading():a("calcite-list",{displayMode:v,label:this.selectedLayer?.title??this.messagesCommon.untitled},i&&this.selectedLayer?a(c,null,this.renderFilter(),this.renderFeatureCountWarning(),this._renderAssociatedFeatureListPage(),this.renderFeatureObserver()):Array.from(e.keys(),(t=>this._renderTypeList(t,e.get(t))))))}_showAllAssociations(e){const{flowItems:t,viewModel:i,description:s}=this;if(!t||!e)return;i.showAllEnabled=!0;const o=new f({selectedLayer:e,title:e?.title,flowItems:t,parentFeatureViewModel:this.parentFeatureViewModel,featureVisibleElements:this.featureVisibleElements,description:s,visibleElements:new l({title:!1,description:!1}),viewModel:i});t.push(o)}_renderAssociatedFeatureListPage(){const e=this.viewModel.associationViewModels.get(this.selectedLayer).filter((e=>o(e.featureViewModel).toLowerCase().includes(this.filterText))).slice(0,this.endIndex);return[...this._renderTooltips(e),...this._renderAssociatedFeatureList(e)]}_renderItemTooltip(e){const{tooltipReferenceMap:t}=this;return m(e.association)?a("calcite-tooltip",{key:`tooltip-${e.featureViewModel.uid}`,overlayPositioning:"fixed",referenceElement:t.get(e.featureViewModel.uid)},this.getConnectivityTooltip(e.association.associationType)):null}_renderAssociatedFeature(e){const{featureViewModel:i}=e,s=o(i),l="loading"===i.state,r=this._findFlowItem(i),n=r<0&&this._isParentFeature(i),c=n||r>=0;return a("calcite-list-item",{class:l?b.listItemHidden:void 0,description:t(e.terminalName??""),key:`associated-feature-type-${i.uid}`,label:t(s),onCalciteListItemSelect:()=>this._handleFeatureClick(n,r,i)},m(e.association)?this.renderConnectivityIcon(e.association.associationType,e.featureViewModel.uid):null,h(e.association)?a("calcite-chip",{label:u(e.association),scale:"s",slot:"content-end"},u(e.association)):null,this._renderChevronIconNode(c))}async _selectAssociation(e){const{flowItems:t,featureVisibleElements:i}=this;if(!t)return;e.abilities={utilityNetworkAssociationsContent:!0};const{default:s}=await import("../Feature.js");t.push(new s({flowItems:t,flowType:"feature-association",viewModel:e,visibleElements:i}))}_handleFeatureClick(e,t,i){if(e)this.flowItems.drain((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}));else if(t<0||!this.flowItems)this._selectAssociation(i);else for(;this.flowItems.length>t+1;){const e=this.flowItems.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy())}}_featureViewModelMatch(e,t){const i=e.graphic,s=i?.layer;let o=null;"subtype-sublayer"===s?.type&&s.parent?o=s.parent.globalIdField??null:s&&"globalIdField"in s&&(o=s.globalIdField);const l=o?i?.attributes[o]:null,r=t.graphic,n=r?.layer;let a=null;"subtype-sublayer"===n?.type&&n.parent?a=n.parent.globalIdField??null:n&&"globalIdField"in n&&(a=n.globalIdField);const c=a?r?.attributes[a]:null;return l&&c&&l===c}_isParentFeature(e){const t=this.flowItems?.getItemAt(0);if(!t)return!1;const i=t.parentFeatureViewModel;return this._featureViewModelMatch(i,e)}_findFlowItem(e){return this.flowItems?.findIndex((t=>{if("feature-association"!==t.flowType)return!1;const i=t.viewModel;return this._featureViewModelMatch(i,e)}))??-1}_renderTooltips(e){return e.toArray().map((e=>this._renderItemTooltip(e)))}_renderAssociatedFeatureList(e){return e.toArray().map((e=>this._renderAssociatedFeature(e)))}_renderChevronIconNode(e){return a("calcite-icon",{flipRtl:!0,icon:e?"move-up":"chevron-right",scale:"s",slot:"content-end"})}_renderTypeList(e,t){const{messagesFeature:i}=this,{displayCount:s}=this.viewModel,o=t.slice(0,s),l=o.length<t.length;return a("calcite-list-item",{key:"show-all",label:e.title,open:!0,value:e.id},a("calcite-chip",{label:String(t.length),scale:"s",slot:"actions-end"},t.length),a("calcite-list",{group:e.id,label:e.title??""},[this._renderTooltips(o),this._renderAssociatedFeatureList(o)],l?a("calcite-list-item",{description:w(i?.numberRecords,{number:t.length.toString()}),key:"show-all-item",label:i.showAll,onCalciteListItemSelect:()=>this._showAllAssociations(e)},a("calcite-icon",{icon:"list",scale:"s",slot:"content-end"})):null))}};e([i()],g.prototype,"description",void 0),e([i()],g.prototype,"featureVisibleElements",void 0),e([i()],g.prototype,"flowItems",void 0),e([i()],g.prototype,"flowType",void 0),e([i()],g.prototype,"listType",void 0),e([i()],g.prototype,"parentFeatureViewModel",void 0),e([i()],g.prototype,"title",void 0),e([i({type:d})],g.prototype,"viewModel",void 0),e([i({type:l,nonNullable:!0})],g.prototype,"visibleElements",void 0),g=f=e([s("esri.widgets.Feature.FeatureUtilityNetworkAssociationList")],g);const M=g;export{M as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{stripHTML as t}from"../../core/string.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{getFeaturePopupTitle as o}from"../../support/popupUtils.js";import l from"./FeatureUtilityNetworkAssociations/VisibleElements.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import{globalCss as n}from"../support/globalCss.js";import"../support/widgetUtils.js";import{tsx as a,tsxFragment as c}from"../support/jsxFactory.js";import d from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import p from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{formatPercentAlong as u}from"../support/UtilityNetworkAssociations/utils/formatPercentAlong.js";import{isConnectivity as m}from"../support/UtilityNetworkAssociations/utils/isConnectivity.js";import{isConnectivityMidspan as h}from"../support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js";import{substitute as w}from"../../intl/substitute.js";var f;const y="esri-feature-utility-network-associations",b={base:y,listItemHidden:`${y}__list-item--hidden`},v="nested";let g=f=class extends p{constructor(e,t){super(e,t),this.description=null,this.flowItems=null,this.flowType="feature-utility-network-association-type",this.listType=null,this.parentFeatureViewModel=null,this.title=null,this.viewModel=new d,this.visibleElements=new l}initialize(){this.setUpObserver()}loadDependencies(){return r({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this.tooltipReferenceMap.clear()}render(){const e=this.viewModel.associationViewModels,{state:t,showAllEnabled:i}=this.viewModel,{state:s}=this.parentFeatureViewModel??{};return a("div",{class:this.classes(b.base,n.widget)},"loading"===t||"querying"===t||"loading"===s?this.renderLoading():a("calcite-list",{displayMode:v,label:this.selectedLayer?.title??this.messagesCommon.untitled},i&&this.selectedLayer?a(c,null,this.renderFilter(),this.renderFeatureCountWarning(),this._renderAssociatedFeatureListPage(),this.renderFeatureObserver()):Array.from(e.keys(),(t=>this._renderTypeList(t,e.get(t))))))}_showAllAssociations(e){const{flowItems:t,viewModel:i,description:s}=this;if(!t||!e)return;i.showAllEnabled=!0;const o=new f({selectedLayer:e,title:e?.title,flowItems:t,parentFeatureViewModel:this.parentFeatureViewModel,featureVisibleElements:this.featureVisibleElements,description:s,visibleElements:new l({title:!1,description:!1}),viewModel:i});t.push(o)}_renderAssociatedFeatureListPage(){const e=this.viewModel.associationViewModels.get(this.selectedLayer).filter((e=>o(e.featureViewModel).toLowerCase().includes(this.filterText))).slice(0,this.endIndex);return[...this._renderTooltips(e),...this._renderAssociatedFeatureList(e)]}_renderItemTooltip(e){const{tooltipReferenceMap:t}=this;return m(e.association)?a("calcite-tooltip",{key:`tooltip-${e.featureViewModel.uid}`,overlayPositioning:"fixed",referenceElement:t.get(e.featureViewModel.uid)},this.getConnectivityTooltip(e.association.associationType)):null}_renderAssociatedFeature(e){const{featureViewModel:i}=e,s=o(i),l="loading"===i.state,r=this._findFlowItem(i),n=r<0&&this._isParentFeature(i),c=n||r>=0;return a("calcite-list-item",{class:l?b.listItemHidden:void 0,description:t(e.terminalName??""),key:`associated-feature-type-${i.uid}`,label:t(s),onCalciteListItemSelect:()=>this._handleFeatureClick(n,r,i)},m(e.association)?this.renderConnectivityIcon(e.association.associationType,e.featureViewModel.uid):null,h(e.association)?a("calcite-chip",{label:u(e.association),scale:"s",slot:"content-end"},u(e.association)):null,this._renderChevronIconNode(c))}async _selectAssociation(e){const{flowItems:t,featureVisibleElements:i}=this;if(!t)return;e.abilities={utilityNetworkAssociationsContent:!0};const{default:s}=await import("../Feature.js");t.push(new s({flowItems:t,flowType:"feature-association",viewModel:e,visibleElements:i}))}_handleFeatureClick(e,t,i){if(e)this.flowItems.drain((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}));else if(t<0||!this.flowItems)this._selectAssociation(i);else for(;this.flowItems.length>t+1;){const e=this.flowItems.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy())}}_featureViewModelMatch(e,t){const i=e.graphic,s=i?.layer;let o=null;"subtype-sublayer"===s?.type&&s.parent?o=s.parent.globalIdField??null:s&&"globalIdField"in s&&(o=s.globalIdField);const l=o?i?.attributes[o]:null,r=t.graphic,n=r?.layer;let a=null;"subtype-sublayer"===n?.type&&n.parent?a=n.parent.globalIdField??null:n&&"globalIdField"in n&&(a=n.globalIdField);const c=a?r?.attributes[a]:null;return l&&c&&l===c}_isParentFeature(e){const t=this.flowItems?.getItemAt(0);if(!t)return!1;const i=t.parentFeatureViewModel;return this._featureViewModelMatch(i,e)}_findFlowItem(e){return this.flowItems?.findIndex((t=>{if("feature-association"!==t.flowType)return!1;const i=t.viewModel;return this._featureViewModelMatch(i,e)}))??-1}_renderTooltips(e){return e.toArray().map((e=>this._renderItemTooltip(e)))}_renderAssociatedFeatureList(e){return e.toArray().map((e=>this._renderAssociatedFeature(e)))}_renderChevronIconNode(e){return a("calcite-icon",{flipRtl:!0,icon:e?"move-up":"chevron-right",scale:"s",slot:"content-end"})}_renderTypeList(e,t){const{messagesFeature:i}=this,{displayCount:s}=this.viewModel,o=t.slice(0,s),l=o.length<t.length;return a("calcite-list-item",{key:"show-all",label:e.title,open:!0,value:e.id},a("calcite-chip",{label:String(t.length),scale:"s",slot:"content-end"},t.length),a("calcite-list",{group:e.id,label:e.title??""},[this._renderTooltips(o),this._renderAssociatedFeatureList(o)],l?a("calcite-list-item",{description:w(i?.numberRecords,{number:t.length.toString()}),key:"show-all-item",label:i.showAll,onCalciteListItemSelect:()=>this._showAllAssociations(e)},a("calcite-icon",{icon:"list",scale:"s",slot:"content-end"})):null))}};e([i()],g.prototype,"description",void 0),e([i()],g.prototype,"featureVisibleElements",void 0),e([i()],g.prototype,"flowItems",void 0),e([i()],g.prototype,"flowType",void 0),e([i()],g.prototype,"listType",void 0),e([i()],g.prototype,"parentFeatureViewModel",void 0),e([i()],g.prototype,"title",void 0),e([i({type:d})],g.prototype,"viewModel",void 0),e([i({type:l,nonNullable:!0})],g.prototype,"visibleElements",void 0),g=f=e([s("esri.widgets.Feature.FeatureUtilityNetworkAssociationList")],g);const M=g;export{M 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.33/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../core/has.js";import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as n,formatDate as r}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l,isTimeOnlyField as u}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as s}from"../../../layers/support/layerUtils.js";import{formatAnyDate as f,isAnyDateField as c}from"../../../smartMapping/support/utils.js";import{loadArcade as d}from"../../../support/arcadeOnDemand.js";import{getTimeZoneFormattingOptions as p}from"../../../time/timeZoneUtils.js";const y="esri.widgets.Feature.support.featureUtils",m=()=>e.getLogger(y),b=/href=(""|'')/gi,g=/(\{([^{\r\n]+)\})/g,I=/'/g,h=/^\s*expression\//i,w=/(\n)/gi,T=/[\u00A0-\u9999<>&]/gim,F=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,j=/^(?:mailto:|tel:)/,N="relationships/",Z=n("short-date-short-time");function L(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function q({type:e,value:t,event:n}){try{return"function"==typeof t?t(n):await t}catch(r){return void m().error("error",`An error occurred when calling the "${e}" function`,{error:r,graphic:n.graphic,value:t})}}function x(e=""){if(e)return!j.test(e.trim().toLowerCase())}function E(e){return!!e&&h.test(e)}function v(e,t){if(!t||!E(t)||!e)return;const n=t.replace(h,"").toLowerCase();return e.find((({name:e})=>e.toLowerCase()===n))}function C(e,t){const n=v(t,e?.fieldName);return n?n.title||null:e?e.label||e.fieldName:null}function U(e,t){const n=t.get(e.toLowerCase());return`{${n?.fieldName||e}}`}function A(e){return e.replaceAll(b,"")}function M(e,t){const n=$(t,e);return n?n.name:e}function R(e,t){return e&&e.map((e=>M(e,t)))}function $(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function k(e){return`${e}`.trim()}function D({attributes:e,globalAttributes:t,layer:n,text:r,expressionAttributes:i,fieldInfoMap:o}){return r?O({formattedAttributes:t,template:P(r,{...t,...i,...e},n),fieldInfoMap:o}):""}function O({formattedAttributes:e,template:n,fieldInfoMap:r}){return k(A(t(t(n,(e=>U(e,r))),e)))}function z(e,t,n=!1){const r=t[e];if("string"==typeof r){const i="%27",o=(n?encodeURIComponent(r):r).replaceAll(I,i);t[e]=o}}function G(e,t=!1){const n={...e};return Object.keys(n).forEach((e=>z(e,n,t))),n}function S(e,n,r){const i=(n=k(n))&&"{"!==n[0];return t(e,G(r,i||!1))}function Q(e,t){return e.replaceAll(g,((e,n,r)=>{const i=$(t,r);return i?`{${i.name}}`:n}))}function P(e,t,n){const r=Q(e,n);return r?r.replaceAll(F,((e,n,r)=>S(e,n||r,t))):r}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"subtype-sublayer"===e.type||"sublayer"===e.type)&&"when"in e}function B(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function J(e){return H(e)&&B(e)}function K(e){return!(!(e&&"object"==typeof e&&"createQuery"in e&&"getField"in e&&"queryFeatureCount"in e&&"queryFeatures"in e&&"queryObjectIds"in e&&"capabilities"in e&&"fields"in e&&"fieldsIndex"in e&&"type"in e)||"feature"!==e.type&&"subtype-group"!==e.type&&"subtype-sublayer"!==e.type&&"sublayer"!==e.type||!("when"in e))&&("subtype-sublayer"===e.type&&"parent"in e&&e.parent&&"object"==typeof e.parent?"globalIdField"in e.parent:"globalIdField"in e)}function V(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&J(e.sourceLayer)}function W(e,t){const{fieldInfos:n,fieldName:r,preventPlacesFormatting:l,layer:u,timeZone:s}=t,c=ee(n,r),d=$(u,r);if(c&&!a(r)){const t=d?.type,n=c.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||n)return f(e,{format:n,fieldType:t,timeZoneOptions:{layerTimeZone:u&&"preferredTimeZone"in u?u.preferredTimeZone:null,viewTimeZone:s,datesInUnknownTimezone:!(!u||!("datesInUnknownTimezone"in u))&&!!u.datesInUnknownTimezone}})}const p=c?.format;return"string"==typeof e&&a(r)&&p?X(e,p):"string"==typeof(e=_(e,p))||null==e||null==p?le(e):i(e,l?{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}:o(p))}function X(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?Y(e,",",", ",t):e.includes(";")?Y(e,";","; ",t):e.includes(" ")?Y(e," "," ",t):i(Number(e),o(t))}function Y(e,t,n,r){return e.trim().split(t).map((e=>i(Number(e),o(r)))).join(n)}function ee(e,t){if(e?.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function te({fieldName:e,graphic:t,layer:n}){if(pe(e))return null;if(!n||"function"!=typeof n.getFeatureType)return null;const{typeIdField:r}=n;if(!r||e!==r)return null;const i=n.getFeatureType(t);return i?i.name:null}function ne({fieldName:e,value:t,graphic:n,layer:r}){if(pe(e))return null;if(!r||"function"!=typeof r.getFieldDomain)return null;const i=n&&r.getFieldDomain(e,{feature:n,excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")});return i&&"coded-value"===i.type?i.getName(t):null}function re(e,t,n,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=p(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,n,Z,"date"),f={...Z,...s},c=t[u];if("number"==typeof c){const e=t[l];return{type:"edit",date:r(c,f),user:e}}const d=t[a];if("number"==typeof d){const e=t[o];return{type:"create",date:r(d,f),user:e}}return null}function ie(e,t){const n=new Map;if(!e)return n;for(const r of e){if(!r.fieldName)continue;const e=M(r.fieldName,t);r.fieldName=e,n.set(e.toLowerCase(),r)}return n}function oe(e){const t=[];if(!e)return t;const{fieldInfos:n,content:r}=e;return n&&t.push(...n),r&&Array.isArray(r)?(r.forEach((e=>{if("fields"===e.type){const n=e?.fieldInfos;n&&t.push(...n)}})),t):t}function ae(e){return e.replaceAll(T,(e=>`&#${e.charCodeAt(0)};`))}function le(e){return"string"==typeof e?e.replaceAll(w,'<br class="esri-text-new-line" />'):e}function ue(e){const{value:t,fieldName:n,fieldInfos:r,fieldInfoMap:i,layer:o,graphic:a,timeZone:l}=e;if(null==t)return"";const s=ne({fieldName:n,value:t,graphic:a,layer:o});if(s)return s;const d=te({fieldName:n,graphic:a,layer:o});if(d)return d;if(i.get(n.toLowerCase()))return W(t,{fieldInfos:r||Array.from(i.values()),fieldName:n,layer:o,timeZone:l});const p=o?.fieldsIndex?.get(n);return p&&(c(p)||u(p))?f(t,{fieldType:p.type,timeZoneOptions:{layerTimeZone:o&&"preferredTimeZone"in o?o.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!o||!("datesInUnknownTimezone"in o))&&!!o.datesInUnknownTimezone}}):le(t)}function se({fieldInfos:e,attributes:t,layer:n,graphic:r,fieldInfoMap:i,relatedInfos:o,timeZone:a}){const l={};return o?.forEach((t=>be({attributes:l,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:n,timeZone:a}))),t&&Object.keys(t).forEach((o=>{const u=t[o];l[o]=ue({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:n,value:u,graphic:r,timeZone:a})})),l}async function fe(e,t){const{layer:n,graphic:r,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:n,graphic:r,objectId:u,requiredFields:i};return m().warn(e,t),null}if(!s(n)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:n,graphic:r,requiredFields:i,returnGeometry:a};return m().warn(e,t),null}const f=n.createQuery();f.objectIds=o,f.outFields=i?.length?i:[n.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await n.queryFeatures(f,t)).features[0]}async function ce(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{hasGeometryFunctions:n}}=t;return n(e)}async function de({graphic:e,popupTemplate:t,layer:n,spatialReference:r},i){if(!n||!t)return;if("function"==typeof n.load&&await n.load(i),!e.attributes)return;const o=n.objectIdField,a=e.attributes[o];if(null==a)return;const u=[a],s=await t.getRequiredFields(n.fieldsIndex),f=l(s,e),c=f?[]:s.includes(o)?s:[...s,o],d=t.returnGeometry||await ce(t);if(f&&!d)return;const p=await fe({layer:n,graphic:e,outFields:c,objectIds:u,returnGeometry:d,spatialReference:r},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function pe(e=""){return!!e&&e.includes(N)}function ye(e){return`${N}${e.layerId}/${e.fieldName}`}function me({attributes:e,graphic:t,relatedInfo:n,fieldInfos:r,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&n&&Object.keys(t.attributes).forEach((l=>{const u=ye({layerId:n.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=ue({fieldName:u,fieldInfos:r,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})}))}function be({attributes:e,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach((a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))),t.relatedStatsFeatures?.forEach((a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},Ie=({layer:e,method:t,query:n,definitionExpression:r})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=n.where?n.where:null,o=null!=n.geometry?n.geometry:null;ge(r)||ge(i)||"extent"===o?.type||"tile"===n.resultType||(n.cacheHint=!0)},he=({query:e,layer:t,method:n})=>{Ie({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},we=({queryPayload:e,layer:t,method:n})=>{Ie({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Te(e,t,n){return e&&t&&n?"sublayer"===t.type?Ne({layers:t.layer?.sublayers,map:e,relatedLayer:t,relationship:n})||Ne({layers:t.layer?.subtables,map:e,relatedLayer:t,relationship:n}):Ne({layers:e.allLayers,map:e,relatedLayer:t,relationship:n})||Ne({layers:e.allTables,map:e,relatedLayer:t,relationship:n}):null}function Fe(e,t){return e&&"utilityNetworks"in e&&t?e.utilityNetworks?.find((e=>e.isUtilityLayer(t))):null}function je(e,t){return e?.allTables.find((e=>"feature"===e.type&&e.layerId===t.id&&e.url===t.layer?.url))}function Ne({map:e,relationship:t,relationship:{relatedTableId:n},relatedLayer:r,layers:i}){if(!i)return null;for(const o of i){if("map-image"===o.type){const n=Ne({layers:o.sublayers,map:e,relatedLayer:r,relationship:t})||Ne({layers:o.subtables,map:e,relatedLayer:r,relationship:t});if(n)return n;continue}if(!J(o))continue;if("sublayer"===r.type){if(o!==r&&o.id===n)return o.isTable?je(e,o):o;continue}const i="scene"===r.type&&r.associatedLayer?r.associatedLayer.url:r.url;if(!i)return null;if("sublayer"!==o.type){if(o!==r&&o.url===i&&o.layerId===n)return o}else if(o!==r&&o.layer?.url===i&&o.id===n)return o.isTable?je(e,o):o}return null}function Ze(e){const t=e.getObjectId();return null!=t?`oid:${t}`:`uid:${e.uid}`}export{le as applyTextFormattingHTML,ie as createFieldInfoMap,Te as findRelatedLayer,Fe as findUtilityNetwork,Q as fixTokens,se as formatAttributes,re as formatEditInfo,W as formatValueToFieldInfo,oe as getAllFieldInfos,ee as getFieldInfo,C as getFieldInfoLabel,M as getFixedFieldName,R as getFixedFieldNames,Ze as getHighlightKeyForFeature,L as getSourceLayer,q as graphicCallback,ae as htmlEntities,K as isAssociatedFeatureSupportedLayer,E as isExpressionField,H as isFeatureSupportedLayer,V as isGraphicForRelatableFeatureSupportedLayer,J as isRelatableFeatureSupportedLayer,B as isRelatableLayer,pe as isRelatedField,he as preLayerQueryCallback,we as preRequestCallback,fe as querySourceLayer,de as queryUpdatedFeature,x as shouldOpenInNewTab,O as substituteAttributes,D as substituteFieldsInLinksAndAttributes};
5
+ import has from"../../../core/has.js";import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as n,formatDate as r}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l,isTimeOnlyField as u}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as s}from"../../../layers/support/layerUtils.js";import{formatAnyDate as f,isAnyDateField as c}from"../../../smartMapping/support/utils.js";import{loadArcade as d}from"../../../support/arcadeOnDemand.js";import{getTimeZoneFormattingOptions as p}from"../../../time/timeZoneUtils.js";const y="esri.widgets.Feature.support.featureUtils",m=()=>e.getLogger(y),b=/href=(""|'')/gi,g=/(\{([^{\r\n]+)\})/g,I=/'/g,h=/^\s*expression\//i,w=/(\n)/gi,T=/[\u00A0-\u9999<>&]/gim,F=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,j=/^(?:mailto:|tel:)/,N="relationships/",Z=n("short-date-short-time");function L(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function q({type:e,value:t,event:n}){try{return"function"==typeof t?t(n):await t}catch(r){return void m().error("error",`An error occurred when calling the "${e}" function`,{error:r,graphic:n.graphic,value:t})}}function x(e=""){if(e)return!j.test(e.trim().toLowerCase())}function E(e){return!!e&&h.test(e)}function v(e,t){if(!t||!E(t)||!e)return;const n=t.replace(h,"").toLowerCase();return e.find((({name:e})=>e.toLowerCase()===n))}function C(e,t){const n=v(t,e?.fieldName);return n?n.title||null:e?e.label||e.fieldName:null}function U(e,t){const n=t.get(e.toLowerCase());return`{${n?.fieldName||e}}`}function A(e){return e.replaceAll(b,"")}function M(e,t){const n=$(t,e);return n?n.name:e}function R(e,t){return e&&e.map((e=>M(e,t)))}function $(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function k(e){return`${e}`.trim()}function D({attributes:e,globalAttributes:t,layer:n,text:r,expressionAttributes:i,fieldInfoMap:o}){return r?O({formattedAttributes:t,template:P(r,{...t,...i,...e},n),fieldInfoMap:o}):""}function O({formattedAttributes:e,template:n,fieldInfoMap:r}){return k(A(t(t(n,(e=>U(e,r))),e)))}function z(e,t,n=!1){const r=t[e];if("string"==typeof r){const i="%27",o=(n?encodeURIComponent(r):r).replaceAll(I,i);t[e]=o}}function G(e,t=!1){const n={...e};return Object.keys(n).forEach((e=>z(e,n,t))),n}function S(e,n,r){const i=(n=k(n))&&"{"!==n[0];return t(e,G(r,i||!1))}function Q(e,t){return e.replaceAll(g,((e,n,r)=>{const i=$(t,r);return i?`{${i.name}}`:n}))}function P(e,t,n){const r=Q(e,n);return r?r.replaceAll(F,((e,n,r)=>S(e,n||r,t))):r}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"subtype-group"===e.type||"subtype-sublayer"===e.type||"sublayer"===e.type)&&"when"in e}function B(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function J(e){return H(e)&&B(e)}function K(e){return!(!(e&&"object"==typeof e&&"createQuery"in e&&"getField"in e&&"queryFeatureCount"in e&&"queryFeatures"in e&&"queryObjectIds"in e&&"capabilities"in e&&"fields"in e&&"fieldsIndex"in e&&"type"in e)||"feature"!==e.type&&"subtype-group"!==e.type&&"subtype-sublayer"!==e.type&&"sublayer"!==e.type||!("when"in e))&&("subtype-sublayer"===e.type&&"parent"in e&&e.parent&&"object"==typeof e.parent?"globalIdField"in e.parent:"globalIdField"in e)}function V(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&J(e.sourceLayer)}function W(e,t){const{fieldInfos:n,fieldName:r,preventPlacesFormatting:l,layer:u,timeZone:s}=t,c=ee(n,r),d=$(u,r);if(c&&!a(r)){const t=d?.type,n=c.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||n)return f(e,{format:n,fieldType:t,timeZoneOptions:{layerTimeZone:u&&"preferredTimeZone"in u?u.preferredTimeZone:null,viewTimeZone:s,datesInUnknownTimezone:!(!u||!("datesInUnknownTimezone"in u))&&!!u.datesInUnknownTimezone}})}const p=c?.format;return"string"==typeof e&&a(r)&&p?X(e,p):"string"==typeof(e=_(e,p))||null==e||null==p?le(e):i(e,l?{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}:o(p))}function X(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?Y(e,",",", ",t):e.includes(";")?Y(e,";","; ",t):e.includes(" ")?Y(e," "," ",t):i(Number(e),o(t))}function Y(e,t,n,r){return e.trim().split(t).map((e=>i(Number(e),o(r)))).join(n)}function ee(e,t){if(e?.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function te({fieldName:e,graphic:t,layer:n}){if(pe(e))return null;if(!n||"function"!=typeof n.getFeatureType)return null;const{typeIdField:r}=n;if(!r||e!==r)return null;const i=n.getFeatureType(t);return i?i.name:null}function ne({fieldName:e,value:t,graphic:n,layer:r}){if(pe(e))return null;if(!r||"function"!=typeof r.getFieldDomain)return null;const i=n&&r.getFieldDomain(e,{feature:n,excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")});return i&&"coded-value"===i.type?i.getName(t):null}function re(e,t,n,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=p(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,n,Z,"date"),f={...Z,...s},c=t[u];if("number"==typeof c){const e=t[l];return{type:"edit",date:r(c,f),user:e}}const d=t[a];if("number"==typeof d){const e=t[o];return{type:"create",date:r(d,f),user:e}}return null}function ie(e,t){const n=new Map;if(!e)return n;for(const r of e){if(!r.fieldName)continue;const e=M(r.fieldName,t);r.fieldName=e,n.set(e.toLowerCase(),r)}return n}function oe(e){const t=[];if(!e)return t;const{fieldInfos:n,content:r}=e;return n&&t.push(...n),r&&Array.isArray(r)?(r.forEach((e=>{if("fields"===e.type){const n=e?.fieldInfos;n&&t.push(...n)}})),t):t}function ae(e){return e.replaceAll(T,(e=>`&#${e.charCodeAt(0)};`))}function le(e){return"string"==typeof e?e.replaceAll(w,'<br class="esri-text-new-line" />'):e}function ue(e){const{value:t,fieldName:n,fieldInfos:r,fieldInfoMap:i,layer:o,graphic:a,timeZone:l}=e;if(null==t)return"";const s=ne({fieldName:n,value:t,graphic:a,layer:o});if(s)return s;const d=te({fieldName:n,graphic:a,layer:o});if(d)return d;if(i.get(n.toLowerCase()))return W(t,{fieldInfos:r||Array.from(i.values()),fieldName:n,layer:o,timeZone:l});const p=o?.fieldsIndex?.get(n);return p&&(c(p)||u(p))?f(t,{fieldType:p.type,timeZoneOptions:{layerTimeZone:o&&"preferredTimeZone"in o?o.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!o||!("datesInUnknownTimezone"in o))&&!!o.datesInUnknownTimezone}}):le(t)}function se({fieldInfos:e,attributes:t,layer:n,graphic:r,fieldInfoMap:i,relatedInfos:o,timeZone:a}){const l={};return o?.forEach((t=>be({attributes:l,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:n,timeZone:a}))),t&&Object.keys(t).forEach((o=>{const u=t[o];l[o]=ue({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:n,value:u,graphic:r,timeZone:a})})),l}async function fe(e,t){const{layer:n,graphic:r,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:n,graphic:r,objectId:u,requiredFields:i};return m().warn(e,t),null}if(!s(n)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:n,graphic:r,requiredFields:i,returnGeometry:a};return m().warn(e,t),null}const f=n.createQuery();f.objectIds=o,f.outFields=i?.length?i:[n.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await n.queryFeatures(f,t)).features[0]}async function ce(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{hasGeometryFunctions:n}}=t;return n(e)}async function de({graphic:e,popupTemplate:t,layer:n,spatialReference:r},i){if(!n||!t)return;if("function"==typeof n.load&&await n.load(i),!e.attributes)return;const o=n.objectIdField,a=e.attributes[o];if(null==a)return;const u=[a],s=await t.getRequiredFields(n.fieldsIndex),f=l(s,e),c=f?[]:s.includes(o)?s:[...s,o],d=t.returnGeometry||await ce(t);if(f&&!d)return;const p=await fe({layer:n,graphic:e,outFields:c,objectIds:u,returnGeometry:d,spatialReference:r},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function pe(e=""){return!!e&&e.includes(N)}function ye(e){return`${N}${e.layerId}/${e.fieldName}`}function me({attributes:e,graphic:t,relatedInfo:n,fieldInfos:r,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&n&&Object.keys(t.attributes).forEach((l=>{const u=ye({layerId:n.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=ue({fieldName:u,fieldInfos:r,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})}))}function be({attributes:e,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach((a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))),t.relatedStatsFeatures?.forEach((a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:n,fieldInfos:r,layer:i,timeZone:o}))))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},Ie=({layer:e,method:t,query:n,definitionExpression:r})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=n.where?n.where:null,o=null!=n.geometry?n.geometry:null;ge(r)||ge(i)||"extent"===o?.type||"tile"===n.resultType||(n.cacheHint=!0)},he=({query:e,layer:t,method:n})=>{Ie({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},we=({queryPayload:e,layer:t,method:n})=>{Ie({layer:t,method:n,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Te(e,t,n){return e&&t&&n?"sublayer"===t.type?Ne({layers:t.layer?.sublayers,map:e,relatedLayer:t,relationship:n})||Ne({layers:t.layer?.subtables,map:e,relatedLayer:t,relationship:n}):Ne({layers:e.allLayers,map:e,relatedLayer:t,relationship:n})||Ne({layers:e.allTables,map:e,relatedLayer:t,relationship:n}):null}function Fe(e,t){return e&&"utilityNetworks"in e&&t?e.utilityNetworks?.find((e=>e.isUtilityLayer(t))):null}function je(e,t){return e?.allTables.find((e=>"feature"===e.type&&e.layerId===t.id&&e.url===t.layer?.url))}function Ne({map:e,relationship:t,relationship:{relatedTableId:n},relatedLayer:r,layers:i}){if(!i)return null;for(const o of i){if("map-image"===o.type){const n=Ne({layers:o.sublayers,map:e,relatedLayer:r,relationship:t})||Ne({layers:o.subtables,map:e,relatedLayer:r,relationship:t});if(n)return n;continue}if(!J(o))continue;if("sublayer"===r.type){if(o!==r&&o.id===n)return o.isTable?je(e,o):o;continue}const i="scene"===r.type&&r.associatedLayer?r.associatedLayer.url:r.url;if(!i)return null;if("sublayer"!==o.type){if(o!==r&&o.url===i&&o.layerId===n)return o}else if(o!==r&&o.layer?.url===i&&o.id===n)return o.isTable?je(e,o):o}return null}function Ze(e){const t=e.getObjectId();return null!=t?`oid:${t}`:`uid:${e.uid}`}export{le as applyTextFormattingHTML,ie as createFieldInfoMap,Te as findRelatedLayer,Fe as findUtilityNetwork,Q as fixTokens,se as formatAttributes,re as formatEditInfo,W as formatValueToFieldInfo,oe as getAllFieldInfos,ee as getFieldInfo,C as getFieldInfoLabel,M as getFixedFieldName,R as getFixedFieldNames,Ze as getHighlightKeyForFeature,L as getSourceLayer,q as graphicCallback,ae as htmlEntities,K as isAssociatedFeatureSupportedLayer,E as isExpressionField,H as isFeatureSupportedLayer,V as isGraphicForRelatableFeatureSupportedLayer,J as isRelatableFeatureSupportedLayer,B as isRelatableLayer,pe as isRelatedField,he as preLayerQueryCallback,we as preRequestCallback,fe as querySourceLayer,de as queryUpdatedFeature,x as shouldOpenInNewTab,O as substituteAttributes,D as substituteFieldsInLinksAndAttributes};