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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{a8565d1c676f3bfbcebb.js → 002fe1ec63ea33e6972d.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{0610691a0c0d9fbbd6d2.js → 013de5c2955801b329b3.js} +1 -1
  4. package/assets/esri/core/workers/chunks/07163dcbb871f927a580.js +1 -0
  5. package/assets/esri/core/workers/chunks/0e46687004392c493c06.js +1 -0
  6. package/assets/esri/core/workers/chunks/0e65e00173b66c7fec2e.js +1 -0
  7. package/assets/esri/core/workers/chunks/1aa8dd317ecd3c41e0ea.js +1 -0
  8. package/assets/esri/core/workers/chunks/21328f3dd26abe84a10d.js +1 -0
  9. package/assets/esri/core/workers/chunks/28c67c98039503b62e6e.js +1 -0
  10. package/assets/esri/core/workers/chunks/{da57eba2fe25495ea217.js → 2faa8f08f2fdaac3f4af.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{0407bf97ad621c89a734.js → 3160af63b860b52db389.js} +1 -1
  12. package/assets/esri/core/workers/chunks/3767b9e7660873b018c2.js +1 -0
  13. package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +1 -0
  14. package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +1 -0
  15. package/assets/esri/core/workers/chunks/4a4f14a3d8da270059c4.js +1 -0
  16. package/assets/esri/core/workers/chunks/{3e239bfad611985e50fb.js → 50f910797c17c3028521.js} +1 -1
  17. package/assets/esri/core/workers/chunks/642c5a93c0a454bdd115.js +1 -0
  18. package/assets/esri/core/workers/chunks/{14145959a3dab1437818.js → 6627f1bc9ee6b620e3aa.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{170bdbdb4e21bf91a17f.js → 6eaa7a51efde2dd4a5a4.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{2bdc63395c7466ce1641.js → 7053c2f5a958d4c8629b.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{4c35c663528f710e8c78.js → 79cb672c85ea29e8484a.js} +1 -1
  22. package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +1 -0
  23. package/assets/esri/core/workers/chunks/89001ee8d3f69fa03cc1.js +1 -0
  24. package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +1 -0
  25. package/assets/esri/core/workers/chunks/9472184ef1432fc55d6b.js +1 -0
  26. package/assets/esri/core/workers/chunks/a6ddf80eb324c35076e1.js +1 -0
  27. package/assets/esri/core/workers/chunks/a80a6267d88246ede5d3.js +1 -0
  28. package/assets/esri/core/workers/chunks/{f505ebd4bd3bfb6c790d.js → b6a55fdfe16795ebf02c.js} +1 -1
  29. package/assets/esri/core/workers/chunks/bf9e1fde9f6b2b4f10c0.js +1 -0
  30. package/assets/esri/core/workers/chunks/cfa3b2b1e184681e9af4.js +1 -0
  31. package/assets/esri/core/workers/chunks/{1f69fb9687de9ebfcf90.js → d4ba894a2583f3930a4f.js} +1 -1
  32. package/assets/esri/core/workers/chunks/d5dfd3d693d5e393a542.js +1 -0
  33. package/assets/esri/core/workers/chunks/{74fd2059ddda9083cbcc.js → dc6c97a43d642eeaf477.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{2154d395f405be3cd3ba.js → eca0c3d57b3a1e3a14ee.js} +1 -1
  35. package/assets/esri/core/workers/chunks/f36697f6aac782007d1a.js +1 -0
  36. package/assets/esri/core/workers/chunks/f52054f27619a98b7bb7.js +1 -0
  37. package/assets/esri/core/workers/chunks/fb7fe307a583b6a22218.js +1 -0
  38. package/assets/esri/core/workers/chunks/fbd3c78ee8e2219a6c7a.js +1 -0
  39. package/assets/esri/core/workers/chunks/ff42585e1b1d0c5497af.js +1 -0
  40. package/assets/esri/images/portal/livestreamvideolayer16.png +0 -0
  41. package/assets/esri/images/portal/{mediaservice16.png → videolayer16.png} +0 -0
  42. package/assets/esri/themes/base/widgets/_FeatureForm.scss +19 -2
  43. package/assets/esri/themes/dark/main.css +1 -1
  44. package/assets/esri/themes/light/main.css +1 -1
  45. package/assets/esri/themes/light/view.css +1 -1
  46. package/geometry/support/DoubleArray.js +1 -1
  47. package/interfaces.d.ts +84 -0
  48. package/kernel.js +1 -1
  49. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  50. package/layers/support/editableLayers.js +1 -1
  51. package/layers/support/layerUtils.js +1 -1
  52. package/package.json +1 -1
  53. package/portal/PortalItem.js +1 -1
  54. package/request.js +1 -1
  55. package/support/requestUtils.js +1 -1
  56. package/support/revision.js +1 -1
  57. package/views/3d/layers/I3SMeshView3D.js +1 -1
  58. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  59. package/views/3d/layers/SceneLayerWorker.js +1 -1
  60. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  61. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  62. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
  63. package/webmap/initialViewPropertiesUtils.js +1 -1
  64. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  65. package/widgets/Editor/CreateWorkflow.js +1 -1
  66. package/widgets/Editor/EditorViewModel.js +1 -1
  67. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  68. package/widgets/Editor/UpdateWorkflow.js +1 -1
  69. package/widgets/Editor/UpdateWorkflowData.js +1 -1
  70. package/widgets/Editor/workflowUtils.js +1 -1
  71. package/widgets/Feature/support/featureUtils.js +1 -1
  72. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  73. package/widgets/FeatureForm/RelationshipInput.js +1 -1
  74. package/widgets/FeatureForm/css.js +1 -1
  75. package/widgets/FeatureForm.js +1 -1
  76. package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
  77. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.d.ts +4 -0
  78. package/widgets/UtilityNetworkValidateTopology.d.ts +4 -0
  79. package/widgets/support/geolocationUtils.js +1 -1
  80. package/assets/esri/core/workers/chunks/0fcb8d408696075338e2.js +0 -1
  81. package/assets/esri/core/workers/chunks/16e459b16bdd6e1a821b.js +0 -1
  82. package/assets/esri/core/workers/chunks/1b8074269800b384ecf6.js +0 -1
  83. package/assets/esri/core/workers/chunks/2b55295590b4a0503749.js +0 -1
  84. package/assets/esri/core/workers/chunks/3ba2fcb9110230f8790c.js +0 -1
  85. package/assets/esri/core/workers/chunks/5576858f56314afcb4d5.js +0 -1
  86. package/assets/esri/core/workers/chunks/5706edf45402dff279a6.js +0 -1
  87. package/assets/esri/core/workers/chunks/659b7bad7281c0e2aed3.js +0 -1
  88. package/assets/esri/core/workers/chunks/6cd248d065f6d1616294.js +0 -1
  89. package/assets/esri/core/workers/chunks/9326120c750799eb2d28.js +0 -1
  90. package/assets/esri/core/workers/chunks/99e0cec47e3ef72c1de4.js +0 -1
  91. package/assets/esri/core/workers/chunks/9c0e1e87790424f42d7e.js +0 -1
  92. package/assets/esri/core/workers/chunks/9e66af3b1c70cf25fb32.js +0 -1
  93. package/assets/esri/core/workers/chunks/a1c31bb8c12831539328.js +0 -1
  94. package/assets/esri/core/workers/chunks/b0cda39b53ecd6c44cd0.js +0 -1
  95. package/assets/esri/core/workers/chunks/c08e03165043df67c11b.js +0 -1
  96. package/assets/esri/core/workers/chunks/c26148d4bfab3b3dfab2.js +0 -1
  97. package/assets/esri/core/workers/chunks/d6b6bb8aecc85d2a3f6b.js +0 -1
  98. package/assets/esri/core/workers/chunks/eeaf8010e38b65a101ac.js +0 -1
  99. package/assets/esri/core/workers/chunks/f235392c56063fbf89c6.js +0 -1
  100. package/assets/esri/core/workers/chunks/fdd0d3616c97e408b104.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as o,getEffectiveEditingEnabled as r}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as s}from"../../views/draw/support/helpMessageUtils.js";import n from"./CreateWorkflowData.js";import{Edits as d}from"./Edits.js";import l from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as c,createWorkflowSteps as w,avoidFeatureTemplateSelectionWithOnlyOneItem as p,setUpFeatureAdd as u,findLayerInfo as f,prepareAttachmentsForCreateWorkflow as m,getVisualVariableAttributes as h,startUpdatingFeature as g,visualVariableInteractiveUpdate as v,updateGraphicSymbolWhenRequired as y}from"./workflowUtils.js";var M;let V=M=class extends l{constructor(e){super(e),this.type="create"}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&c(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get hasPendingEdits(){return!0}get helpMessage(){if("editing-new-feature"!==this.stepId)return;const{creationInfo:e,viewModel:t}=this.data,a=t.sketchViewModel.createGraphic?.geometry,i=e.layer.geometryType;return s(i,a,t.view)}get reliesOnOwnerAdminPrivileges(){const{layer:e}=this.data.creationInfo,t=e.capabilities?.operations.supportsAdd,a=o(e)?.operations.supportsAdd;return r(e)&&!e.editingEnabled||!!a&&!t}static create(e,t,a){const i=new M({data:new n({edits:new d,viewModel:e}),onCommit:async e=>{await a(e.creationInfo.layer,{addFeatures:[e.edits.feature]})}});return i._set("steps",this._createWorkflowSteps(i,t)),i}static _createWorkflowSteps(e,a="awaiting-feature-creation-info"){const{data:i,handles:o}=e,r=new Map,s=w(["awaiting-feature-creation-info","awaiting-feature-to-create","editing-new-feature","adding-attachment","editing-attachment"],a,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){i.creationInfo=null,i.edits.feature=null,i.viewModel.featureTemplatesViewModel.select(null),o.add(i.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(i.creationInfo=e,i.viewModel.activeWorkflow?.next())})),this.id)},async tearDown(){o.remove(this.id)}}),"awaiting-feature-to-create":()=>({id:"awaiting-feature-to-create",async setUp(){o.add(await u(i.viewModel.sketchViewModel,i.creationInfo,(e=>{i.edits.feature=e,i.viewModel.activeWorkflow?.next()}),r),this.id)},async tearDown(){o.remove(this.id)}}),"editing-new-feature":()=>({id:"editing-new-feature",async setUp(){const e=i.edits.feature,a=e.sourceLayer,s=i.viewModel,n=s.sketchViewModel,d=f(s.layerInfos,a),l=d?.formTemplate,{spatialReference:c}=s.view;s.featureFormViewModel.set({arcadeEditType:"INSERT",feature:e,formTemplate:l,spatialReference:c}),n.allowDeleteKey=!1,m(s.attachmentsViewModel);const w=h(e);await g(n,e,a,w,r);const p=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return g(n,t,a,w,r);await v(n.view,t,e,w,r);const i=t.attributes;if(null!=w.rotation){const{field:e}=w.rotation;s.featureFormViewModel.setValue(e,i[e])}if(null!=w.size){const{field:e}=w.size;s.featureFormViewModel.setValue(e,i[e])}}));o.add([i.viewModel.featureFormViewModel.on("value-change",(async()=>{i.edits.updateAttributes(i.viewModel.featureFormViewModel.getValues()),e.attributes=i.edits.feature.attributes,"3d"===n.view.type&&await y(e,r)})),p,t((()=>i.viewModel.attachmentsViewModel.mode),(e=>{"add"===e&&i.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&i.viewModel.activeWorkflow.go("editing-attachment")}))],this.id)},async tearDown(e){e.canceled&&i.viewModel.sketchViewModel.layer.removeAll(),o.remove(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-new-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-new-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})});return p(i,s)}};e([a()],V.prototype,"shouldShowAttachments",null),e([a()],V.prototype,"shouldAllowAttachmentEditing",null),e([a()],V.prototype,"hasPendingEdits",null),e([a()],V.prototype,"helpMessage",null),e([a()],V.prototype,"reliesOnOwnerAdminPrivileges",null),V=M=e([i("esri.widgets.Editor.CreateWorkflow")],V);const k=V;export{k as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as o,getEffectiveEditingEnabled as r}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as s}from"../../views/draw/support/helpMessageUtils.js";import n from"./CreateWorkflowData.js";import{Edits as d}from"./Edits.js";import l from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as c,createWorkflowSteps as w,avoidFeatureTemplateSelectionWithOnlyOneItem as u,setUpFeatureAdd as p,findLayerInfo as f,prepareAttachmentsForCreateWorkflow as m,getVisualVariableAttributes as h,startUpdatingFeature as g,visualVariableInteractiveUpdate as y,updateGraphicSymbolWhenRequired as v}from"./workflowUtils.js";var M;let V=M=class extends l{constructor(e){super(e),this.type="create"}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&c(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get hasPendingEdits(){return!0}get helpMessage(){if("editing-new-feature"!==this.stepId)return;const{creationInfo:e,viewModel:t}=this.data,a=t.sketchViewModel.createGraphic?.geometry,i=e.layer.geometryType;return s(i,a,t.view)}get reliesOnOwnerAdminPrivileges(){const{layer:e}=this.data.creationInfo,t=e.capabilities?.operations.supportsAdd,a=o(e)?.operations.supportsAdd;return r(e)&&!e.editingEnabled||!!a&&!t}static create(e,t,a){const i=new M({data:new n({edits:new d,viewModel:e}),onCommit:async e=>{await a(e.creationInfo.layer,{addFeatures:[e.edits.feature]})}});return i._set("steps",this._createWorkflowSteps(i,t)),i}static _createWorkflowSteps(e,a="awaiting-feature-creation-info"){const{data:i,handles:o}=e,r=new Map,s=w(["awaiting-feature-creation-info","awaiting-feature-to-create","editing-new-feature","adding-attachment","editing-attachment"],a,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){i.creationInfo=null,i.edits.feature=null,i.viewModel.featureTemplatesViewModel.select(null),o.add(i.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(i.creationInfo=e,i.viewModel.activeWorkflow?.next())})),this.id)},async tearDown(){o.remove(this.id)}}),"awaiting-feature-to-create":()=>({id:"awaiting-feature-to-create",async setUp(){o.add(await p(i.viewModel.sketchViewModel,i.creationInfo,(e=>{i.edits.feature=e,i.viewModel.activeWorkflow?.next()}),r),this.id)},async tearDown(){o.remove(this.id)}}),"editing-new-feature":()=>({id:"editing-new-feature",async setUp(){const e=i.edits.feature,a=e.sourceLayer,s=i.viewModel,n=s.sketchViewModel,d=f(s.layerInfos,a),l=d?.formTemplate,{spatialReference:c}=s.view;s.featureFormViewModel.set({arcadeEditType:"INSERT",feature:e,formTemplate:l,spatialReference:c}),n.allowDeleteKey=!1,m(s.attachmentsViewModel);const w=h(e);await g({graphic:e,sketchViewModel:n,sourceLayer:a,visualVariables:w,webStyleCache:r});const u=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return g({graphic:t,sketchViewModel:n,sourceLayer:a,visualVariables:w,webStyleCache:r});await y(n.view,t,e,w,r);const i=t.attributes;if(null!=w.rotation){const{field:e}=w.rotation;s.featureFormViewModel.setValue(e,i[e])}if(null!=w.size){const{field:e}=w.size;s.featureFormViewModel.setValue(e,i[e])}}));o.add([i.viewModel.featureFormViewModel.on("value-change",(async()=>{i.edits.updateAttributes(i.viewModel.featureFormViewModel.getValues()),e.attributes=i.edits.feature.attributes,"3d"===n.view.type&&await v(e,r)})),u,t((()=>i.viewModel.attachmentsViewModel.mode),(e=>{"add"===e&&i.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&i.viewModel.activeWorkflow.go("editing-attachment")}))],this.id)},async tearDown(e){e.canceled&&i.viewModel.sketchViewModel.layer.removeAll(),o.remove(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-new-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-new-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})});return u(i,s)}};e([a()],V.prototype,"shouldShowAttachments",null),e([a()],V.prototype,"shouldAllowAttachmentEditing",null),e([a()],V.prototype,"hasPendingEdits",null),e([a()],V.prototype,"helpMessage",null),e([a()],V.prototype,"reliesOnOwnerAdminPrivileges",null),V=M=e([i("esri.widgets.Editor.CreateWorkflow")],V);const k=V;export{k as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import o from"../../core/Evented.js";import{HandleOwnerMixin as s}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{isEditableLayer as k}from"../../layers/support/editableLayers.js";import{getOwningPortalUrl as g,getEffectiveLayerCapabilities as v,isFeatureLayer as W}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import _ from"../Attachments/AttachmentsViewModel.js";import F from"./CreateFeaturesWorkflow.js";import C from"./CreateWorkflow.js";import{workflowDeprecation as E}from"./deprecationUtils.js";import I from"./UpdateWorkflow.js";import{whenEditorLayerView as U}from"./workflowUtils.js";import{formTemplateHasInvalidFields as A,unsupportedDateFieldTypes as O}from"../FeatureForm/featureFormUtils.js";import V from"../FeatureForm/FeatureFormViewModel.js";import j from"../FeatureTemplates/FeatureTemplatesViewModel.js";import M from"../Sketch/SketchViewModel.js";import T from"../Spinner/SpinnerViewModel.js";const S="esri.widgets.Editor.EditorViewModel",L=n.getLogger(S),P=["create","create-features","update"];function D(t,e,a){L.error(new i(t,e,a))}function G(t,e){return t?t.find((t=>t.layer===e)):void 0}let x=class extends(s(o.EventedAccessor)){constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new _({capabilities:{editing:!0}}),this.featureFormViewModel=new V,this.featureTemplatesViewModel=new j,this.sketchViewModel=new M({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new T,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow())},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0||await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),c((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const o={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(o);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(o):this.startCreateFeaturesWorkflowAtFeatureCreation(o)})),c((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...P]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,o=!(i&&"visible"in i)||!!i.visible;return e.visible&&o&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(L,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1==!!t.activeEditableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditableItem?.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(E(L,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(E(L,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(E(L,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():D("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasInvalidFormTemplate??!1)}itemHasUnsupportedFields(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasUnsupportedFields??!1)}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map,i=r?.editableLayers.toArray()??[],o=r?.allTables.toArray().filter(W)??[];await Promise.all(o.map((t=>t.load())));const s=o.filter((t=>k(t))),n=[...i.reverse(),...s.reverse()];if(!e||!i)return;const l=[],p=[];for(const a of n){const r=e.find((t=>t.layer===a)),i=r?l:p;if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)i.push(this._makeEditableItemForLayer(a.sublayers.at(t),!!r?.suspended))}else i.push(this._makeEditableItemForLayer(a,!!r?.suspended))}if(t.aborted)return;const c=this._editableItems;this._editableItems=new a(l.concat(p)),c.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&D("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return F.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return C.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return I.create(this,t,((t,e)=>this._applyEdits(t,e)))}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await g(t.url):null,o={returnServiceEditsOption:(!i||!b(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const a=await U(this.view,t).catch((()=>null));return r=await t.applyEdits(e,o),a&&await h((()=>!a.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{D("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=v(t),r=a?.operations,i=G(this.layerInfos,t),o=A(t),s=t.fields.some((({type:t})=>O.has(t))),n=o||s,{allowedWorkflows:l}=this,d=l.includes("create")||l.includes("create-features"),p=l.includes("update"),c=t=>!i||!1!==i.enabled&&!1!==i[t],u=d&&!!r?.supportsAdd&&c("addEnabled"),h=p&&!!r?.supportsUpdate&&c("updateEnabled"),w=!n&&p&&!!r?.supportsDelete&&c("deleteEnabled"),f=[];e||(u&&f.push("create"),h&&f.push("update"),w&&f.push("delete"));const m=h&&!n&&(!i||!1!==i.attributeUpdatesEnabled),y=h&&!n&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),k=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:f,attributeUpdatesEnabled:m,geometryUpdatesEnabled:y,hasAttachments:k,attachmentsOnCreateEnabled:k&&d&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:!n&&k&&(!i||!1!==i.attachmentsOnUpdateEnabled),hasInvalidFormTemplate:o,hasUnsupportedFields:s}}};t([f()],x.prototype,"_editableItems",void 0),t([f({readOnly:!0})],x.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],x.prototype,"_activityQueue",void 0),t([f({value:[...P]})],x.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],x.prototype,"canCreate",null),t([f({readOnly:!0})],x.prototype,"canUpdate",null),t([f()],x.prototype,"editableItems",null),t([f({readOnly:!0})],x.prototype,"failures",void 0),t([f()],x.prototype,"attachmentsViewModel",void 0),t([f()],x.prototype,"featureFormViewModel",void 0),t([f()],x.prototype,"featureTemplatesViewModel",void 0),t([f()],x.prototype,"labelOptions",null),t([f()],x.prototype,"layerInfos",null),t([f()],x.prototype,"sketchViewModel",void 0),t([f()],x.prototype,"snappingOptions",null),t([f()],x.prototype,"spinnerViewModel",void 0),t([f()],x.prototype,"state",null),t([f({readOnly:!0})],x.prototype,"syncing",null),t([f()],x.prototype,"updating",null),t([f()],x.prototype,"tooltipOptions",null),t([f()],x.prototype,"view",null),t([f()],x.prototype,"pageStack",void 0),t([f()],x.prototype,"showDiscardEditsPrompt",void 0),t([f()],x.prototype,"_candidateCommitted",void 0),t([f()],x.prototype,"page",null),t([f()],x.prototype,"selectedTemplateItem",null),t([f()],x.prototype,"featureFormDisabled",null),t([f()],x.prototype,"canGoBack",null),t([f()],x.prototype,"shouldShowDeleteButton",null),t([f()],x.prototype,"hasPendingEdits",null),t([f()],x.prototype,"useDeprecatedCreateWorkflow",void 0),x=t([m(S)],x);const B=x;export{B as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{isEditableLayer as k}from"../../layers/support/editableLayers.js";import{getOwningPortalUrl as g,getEffectiveLayerCapabilities as v,isFeatureLayer as b}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as W}from"../../portal/support/urlUtils.js";import _ from"../Attachments/AttachmentsViewModel.js";import F from"./CreateFeaturesWorkflow.js";import C from"./CreateWorkflow.js";import{workflowDeprecation as E}from"./deprecationUtils.js";import I from"./UpdateWorkflow.js";import{whenEditorLayerView as U}from"./workflowUtils.js";import{formTemplateHasInvalidFields as A,unsupportedDateFieldTypes as O}from"../FeatureForm/featureFormUtils.js";import V from"../FeatureForm/FeatureFormViewModel.js";import M from"../FeatureTemplates/FeatureTemplatesViewModel.js";import j from"../Sketch/SketchViewModel.js";import T from"../Spinner/SpinnerViewModel.js";const S="esri.widgets.Editor.EditorViewModel",L=n.getLogger(S),P=["create","create-features","update"];function D(t,e,a){L.error(new i(t,e,a))}function G(t,e){return t?t.find((t=>t.layer===e)):void 0}let x=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new _({capabilities:{editing:!0}}),this.featureFormViewModel=new V,this.featureTemplatesViewModel=new M,this.sketchViewModel=new j({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new T,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0||await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),c((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const s={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(s);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(s):this.startCreateFeaturesWorkflowAtFeatureCreation(s)})),c((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...P]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(L,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditableItem?.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(E(L,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(E(L,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(E(L,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():D("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasInvalidFormTemplate??!1)}itemHasUnsupportedFields(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasUnsupportedFields??!1)}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map,i=r?.editableLayers.toArray()??[],s=r?.allTables.toArray().filter(b)??[];await Promise.all(s.map((t=>t.load())));const o=s.filter((t=>k(t))),n=[...i.reverse(),...o.reverse()].filter((t=>"mesh"!==t.geometryType&&"multipatch"!==t.geometryType||"3d"===this.view?.type));if(!e||!i)return;const l=[],p=[];for(const a of n){const r=e.find((t=>t.layer===a)),i=r?l:p;if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)i.push(this._makeEditableItemForLayer(a.sublayers.at(t),!!r?.suspended))}else i.push(this._makeEditableItemForLayer(a,!!r?.suspended))}if(t.aborted)return;const c=this._editableItems;this._editableItems=new a(l.concat(p)),c.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&D("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return F.create({viewModel:this,creationInfo:t,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createCreateWorkflow(t){return C.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return I.create(this,t,((t,e)=>this._applyEdits(t,e)))}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await g(t.url):null,s={returnServiceEditsOption:(!i||!W(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const a=await U(this.view,t).catch((()=>null));return r=await t.applyEdits(e,s),a&&await h((()=>!a.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{D("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=v(t),r=a?.operations,i=G(this.layerInfos,t),s=A(t),o=t.fields.some((({type:t})=>O.has(t))),n=s||o,{allowedWorkflows:l}=this,d=l.includes("create")||l.includes("create-features"),p=l.includes("update"),c=t=>!i||!1!==i.enabled&&!1!==i[t],u=d&&!!r?.supportsAdd&&c("addEnabled"),h=p&&!!r?.supportsUpdate&&c("updateEnabled"),w=!n&&p&&!!r?.supportsDelete&&c("deleteEnabled"),f=[];e||(u&&f.push("create"),h&&f.push("update"),w&&f.push("delete"));const m=h&&!n&&(!i||!1!==i.attributeUpdatesEnabled),y=h&&!n&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),k=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:f,attributeUpdatesEnabled:m,geometryUpdatesEnabled:y,hasAttachments:k,attachmentsOnCreateEnabled:k&&d&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:!n&&k&&(!i||!1!==i.attachmentsOnUpdateEnabled),hasInvalidFormTemplate:s,hasUnsupportedFields:o}}};t([f()],x.prototype,"_editableItems",void 0),t([f({readOnly:!0})],x.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],x.prototype,"_activityQueue",void 0),t([f({value:[...P]})],x.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],x.prototype,"canCreate",null),t([f({readOnly:!0})],x.prototype,"canUpdate",null),t([f()],x.prototype,"editableItems",null),t([f({readOnly:!0})],x.prototype,"failures",void 0),t([f()],x.prototype,"attachmentsViewModel",void 0),t([f()],x.prototype,"featureFormViewModel",void 0),t([f()],x.prototype,"featureTemplatesViewModel",void 0),t([f()],x.prototype,"labelOptions",null),t([f()],x.prototype,"layerInfos",null),t([f()],x.prototype,"sketchViewModel",void 0),t([f()],x.prototype,"snappingOptions",null),t([f()],x.prototype,"spinnerViewModel",void 0),t([f()],x.prototype,"state",null),t([f({readOnly:!0})],x.prototype,"syncing",null),t([f()],x.prototype,"updating",null),t([f()],x.prototype,"tooltipOptions",null),t([f()],x.prototype,"view",null),t([f()],x.prototype,"pageStack",void 0),t([f()],x.prototype,"showDiscardEditsPrompt",void 0),t([f()],x.prototype,"_candidateCommitted",void 0),t([f()],x.prototype,"page",null),t([f()],x.prototype,"selectedTemplateItem",null),t([f()],x.prototype,"featureFormDisabled",null),t([f()],x.prototype,"canGoBack",null),t([f()],x.prototype,"shouldShowDeleteButton",null),t([f()],x.prototype,"hasPendingEdits",null),t([f()],x.prototype,"useDeprecatedCreateWorkflow",void 0),x=t([m(S)],x);const B=x;export{B as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{sceneLayerEditingEnabled as o,i3sPatchingEnabled as s}from"../../support/featureFlags.js";import{highlightsSupported as a}from"../../views/support/layerViewUtils.js";import l from"./UpdateFeatureWorkflowData.js";import{HANDLE_KEYS as n,UpdateRecordWorkflow as c}from"./UpdateRecordWorkflow.js";import{canCreateInteractiveEditSession as d,getVisualVariableAttributes as h,setUpGeometryUpdate as p,isTerminalUpdateEventType as u}from"./workflowUtils.js";var m;const y={...n,highlights:Symbol(),interactiveGraphics:Symbol(),geometryGraphics:Symbol()};let w=m=class extends c{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._webStyleCache=new Map}async initialize(){const{edits:{feature:e},layerView:t}=this.data;d(t)&&(this._layerViewEditSession=t.createInteractiveEditSession(e))}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(y.interactiveGraphics);try{await super.commit(),this.removeHandles(y.geometryGraphics),this._layerViewEditSession?.commit()}catch(e){throw this.removeHandles(y.geometryGraphics),await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async enter(){await super.enter(),this.data.editableItem.geometryUpdatesEnabled?this.hasHandles(y.interactiveGraphics)||await this._configureSketchViewModel():this._configureHighlight()}exit(e={removeSketchHandles:!0}){super.exit(e),e.removeSketchHandles&&this.removeHandles([y.geometryGraphics,y.interactiveGraphics])}_configureFeatureFormViewModel(){super._configureFeatureFormViewModel();const{_layerViewEditSession:e}=this,{viewModel:t}=this.data;this.addHandles(t.featureFormViewModel.on("value-change",(t=>{e?.setAttribute(t.fieldName,t.value)})),y.exit)}_configureHighlight(){const{edits:e,layerView:t}=this.data;a(t)&&this.addHandles(t.highlight(e.feature),y.highlights)}async _configureSketchViewModel(){const{data:e,_layerViewEditSession:t}=this,{edits:r,viewModel:i}=e,a=r.feature,{featureFormViewModel:l,sketchViewModel:n,view:c}=i;n.allowDeleteKey=!1;const d=h(a),{interactive:m,visual:w}=await p(a,d,n,c,(({geometry:e,attributes:i},n)=>{if(r.updateAttributes(i),r.updateGeometry(e),l.feature.geometry=e,null!=d.rotation){const{field:e}=d.rotation;l.setValue(e,i[e])}if(null!=d.size){const{field:e}=d.size;l.setValue(e,i[e])}const{sourceLayer:c}=a;null!=c&&"scene"===c.type&&null!=c.infoFor3D&&o()&&s()&&t&&null!=e&&"mesh"===e.type&&t.setGeometry(e),("undo"===n.type||"redo"===n.type||"update"===n.type&&null!=n.toolEventInfo&&u(n.toolEventInfo.type))&&l.notifyFeatureGeometryChanged()}),this._webStyleCache);this.addHandles(m,y.interactiveGraphics),this.addHandles(w,y.geometryGraphics)}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const{edits:t}=this.data;t.updateGeometry(e.geometry),t.trackChanges()}static async create(e){const t=new m({data:await l.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}};e([r()],w.prototype,"_layerViewEditSession",void 0),w=m=e([i("esri.widgets.Editor.UpdateFeatureWorkflow")],w);export{y as HANDLE_KEYS,w as UpdateFeatureWorkflow};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{sceneLayerEditingEnabled as o,i3sPatchingEnabled as s}from"../../support/featureFlags.js";import{highlightsSupported as a}from"../../views/support/layerViewUtils.js";import l from"./UpdateFeatureWorkflowData.js";import{HANDLE_KEYS as n,UpdateRecordWorkflow as c}from"./UpdateRecordWorkflow.js";import{canCreateInteractiveEditSession as d,getVisualVariableAttributes as h,setUpGeometryUpdate as p,isTerminalUpdateEventType as u}from"./workflowUtils.js";var m;const y={...n,highlights:Symbol(),interactiveGraphics:Symbol(),geometryGraphics:Symbol()};let w=m=class extends c{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._webStyleCache=new Map}async initialize(){const{edits:{feature:e},layerView:t}=this.data;d(t)&&(this._layerViewEditSession=t.createInteractiveEditSession(e))}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(y.interactiveGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit(),this.removeHandles(y.geometryGraphics);const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw this.removeHandles(y.geometryGraphics),await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async enter(){await super.enter(),this.data.editableItem.geometryUpdatesEnabled?this.hasHandles(y.interactiveGraphics)||await this._configureSketchViewModel():this._configureHighlight()}exit(e={removeSketchHandles:!0}){super.exit(e),e.removeSketchHandles&&this.removeHandles([y.geometryGraphics,y.interactiveGraphics])}_configureFeatureFormViewModel(){super._configureFeatureFormViewModel();const{_layerViewEditSession:e}=this,{viewModel:t}=this.data;this.addHandles(t.featureFormViewModel.on("value-change",(t=>{e?.setAttribute(t.fieldName,t.value)})),y.exit)}_configureHighlight(){const{edits:e,layerView:t}=this.data;a(t)&&this.addHandles(t.highlight(e.feature),y.highlights)}async _configureSketchViewModel(){const{data:e,_layerViewEditSession:t}=this,{edits:r,viewModel:i}=e,a=r.feature,{featureFormViewModel:l,sketchViewModel:n,view:c}=i;n.allowDeleteKey=!1;const d=h(a),{interactive:m,visual:w}=await p(a,d,n,c,(({geometry:e,attributes:i},n)=>{if(r.updateAttributes(i),r.updateGeometry(e),l.feature.geometry=e,null!=d.rotation){const{field:e}=d.rotation;l.setValue(e,i[e])}if(null!=d.size){const{field:e}=d.size;l.setValue(e,i[e])}const{sourceLayer:c}=a;null!=c&&"scene"===c.type&&null!=c.infoFor3D&&o()&&s()&&t&&null!=e&&"mesh"===e.type&&t.setGeometry(e),("undo"===n.type||"redo"===n.type||"update"===n.type&&null!=n.toolEventInfo&&u(n.toolEventInfo.type))&&l.notifyFeatureGeometryChanged()}),this._webStyleCache);this.addHandles(m,y.interactiveGraphics),this.addHandles(w,y.geometryGraphics)}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const{edits:t}=this.data;t.updateGeometry(e.geometry),t.trackChanges()}static async create(e){const t=new m({data:await l.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}};e([r()],w.prototype,"_layerViewEditSession",void 0),w=m=e([i("esri.widgets.Editor.UpdateFeatureWorkflow")],w);export{y as HANDLE_KEYS,w as UpdateFeatureWorkflow};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import{makeHandle as a}from"../../core/handleUtils.js";import{abortMaybe as i}from"../../core/maybe.js";import{onAbort as o,createAbortError as r,throwIfAborted as s,debounce as n}from"../../core/promiseUtils.js";import l from"../../core/Queue.js";import{whenOnce as d,watch as c}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{isNonSpatialTable as u}from"../../layers/support/layerUtils.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import{UpdateFeatureWorkflow as f}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as m}from"./UpdateRecordWorkflow.js";import g from"./UpdateWorkflowData.js";import k from"./Workflow.js";import{createWorkflowSteps as v,fetchCandidates as y}from"./workflowUtils.js";var W;const _="candidate-highlight",b="esri.widgets.Editor.UpdateWorkflow";let S=W=class extends k{constructor(t){super(t),this._workflowStack=new l((t=>{let e;for(e of t);return e})),this.type="update"}initialize(){const{featureFormViewModel:t}=this.data.viewModel,e=t.relatedRecordCallbacks;t.relatedRecordCallbacks={addRelatedRecord:()=>{},editRelatedRecord:({relatedFeature:t})=>this.startUpdating(t)},this.addHandles(a((()=>t.relatedRecordCallbacks=e)))}get activeEditableItem(){const{activeWorkflow:t}=this;return U(t)?t.data.editableItem:void 0}get activeWorkflow(){return this._workflowStack.last()}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditableItem?.attachmentsOnUpdateEnabled}get shouldAllowAttachmentEditing(){return!!this.activeEditableItem?.supports.includes("update")}get hasPendingEdits(){return Array.from(this._workflowStack).some((t=>t.hasPendingEdits))}get helpMessage(){return"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditableItem?.hasInvalidFormTemplate}get hasUnsupportedFields(){return!!this.activeEditableItem?.hasUnsupportedFields}get updating(){return this.updatingHandles.updating}async back(t=(()=>Promise.resolve(!0))){if(this.activeWorkflow){if(this.activeWorkflow.hasPendingEdits){if(!await t())return}this.activeWorkflow.hasPreviousStep?await this.activeWorkflow.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancelActiveWorkflow(t){await(this.activeWorkflow?.cancel(t)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((t=>t.commit())),await super.commit()}static create(t,e,a){const i=new W({data:new g({applyEditsCallback:a,viewModel:t}),onCommit:async()=>{}});return i._set("steps",this._createWorkflowSteps(i,e)),i}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startUpdating(t){try{const e=await this._createNestedWorkflow(t);await this._pushWorkflow(e)}catch(a){throw new e("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}}async deleteActiveFeature(){const{activeWorkflow:t}=this;if(!t)throw new e("editor:nothing-to-delete","There is no feature to delete");U(t)?await t.deleteAndCommit():await t.cancel(),1===this.nestedWorkflowCount?this.emit("complete"):await this._popWorkflow()}async cancelAll(){await this._drainWorkflowStack((t=>t.cancel({force:!0})))}async _createNestedWorkflow(t){const e=u(t.sourceLayer)?m:f,{applyEditsCallback:a,viewModel:i}=this.data,o=await e.create({feature:t,viewModel:i,applyEdits:a});return await d((()=>!o.updating)),o}async _drainWorkflowStack(t){const e=this._workflowStack,a=[];for(;e.length>0;){const i=e.pop(),o=t(i).then((()=>i.destroy()));this.updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_highlight(t){const e=this.data.viewModel.view;if(!e||!t)return;const a=t&&e.allLayerViews.items.find((({layer:e})=>e===t.layer||"subtype-sublayer"===t.layer?.type&&t.layer?.parent===e));h(a)&&this.handles.add(a.highlight(t),_)}async _popWorkflow(){this._workflowStack.pop()?.destroy();const t=await this._reconcileWorkflowStack();if(t.failureCount>0)throw new e("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",t)}async _pushWorkflow(t){const a="update-feature"===t.type||"create-features"===t.type;this.activeWorkflow?.exit({removeSketchHandles:a}),await t.start(),this._workflowStack.push(t);const i=await this._reconcileWorkflowStack();if(i.failureCount>0)throw new e("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",i)}async _reconcileWorkflowStack(){const t=this._workflowStack;try{const e=t.peek();return await(e?.enter()),{activeWorkflow:e,failureCount:0}}catch(e){t.pop().destroy();const{activeWorkflow:a,failureCount:i}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:i+1}}}_unhighlight(){this.handles.remove(_)}static _createWorkflowSteps(t,l="awaiting-feature-to-update"){const{data:p,handles:w}=t;return v(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],l,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e}=p.viewModel,n=p.viewModel.view;let l=null;w.add(a((()=>{l=i(l)})),this.id),p.rootFeature=null,p.candidates=[];const d=n.on("immediate-click",(async a=>{e.location=a.mapPoint,e.visible=!0,l?.abort();const{editableItems:i}=p.viewModel;l=new AbortController;const d=await new Promise(((t,e)=>{o(l?.signal,(()=>e(r()))),t(y(i,n,a,l?.signal))}));s(l),p.candidates=d.reduce(((t,e)=>e.error?t:[...t,...e.value]),[]),e.visible=1===p.candidates.length,0!==p.candidates.length&&(1===p.candidates.length?(p.rootFeature=p.candidates[0],t.go("editing-existing-feature").catch((()=>{})).then((()=>e.visible=!1))):t.next())}));n.focus(),w.add(d,this.id)},async tearDown(){w.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){p.rootFeature=null,w.add(c((()=>p.rootFeature),(e=>{t._unhighlight(),t._highlight(e)})),this.id)},async tearDown(){t._unhighlight(),w.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:a,viewModel:i}=t.data;if(!a)throw new e("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await t.startUpdating(a),i.spinnerViewModel.visible=!1;const o=n((async()=>{await d((()=>!t.updating)),t.previous()}));t.addHandles(c((()=>t.nestedWorkflowCount),((t,e)=>{0===t&&0!==e&&o()})))},async tearDown(){await t.cancelAll()}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){p.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){p.viewModel.attachmentsViewModel.mode="view"}})})}};t([p()],S.prototype,"activeEditableItem",null),t([p()],S.prototype,"activeWorkflow",null),t([p()],S.prototype,"nestedWorkflowCount",null),t([p()],S.prototype,"shouldShowAttachments",null),t([p()],S.prototype,"shouldAllowAttachmentEditing",null),t([p()],S.prototype,"hasPendingEdits",null),t([p()],S.prototype,"helpMessage",null),t([p()],S.prototype,"reliesOnOwnerAdminPrivileges",null),t([p()],S.prototype,"hasInvalidFormTemplate",null),t([p()],S.prototype,"hasUnsupportedFields",null),t([p()],S.prototype,"updating",null),S=W=t([w(b)],S);const U=t=>!!t&&/update-/.test(t.type),C=S;export{C as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{onAbort as s,createAbortError as n,throwIfAborted as l,debounce as d}from"../../core/promiseUtils.js";import c from"../../core/Queue.js";import{whenOnce as p,watch as u}from"../../core/reactiveUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import{isTable as m}from"../../layers/support/layerUtils.js";import{highlightsSupported as g}from"../../views/support/layerViewUtils.js";import k from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as y}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as v}from"./UpdateRecordWorkflow.js";import b from"./UpdateWorkflowData.js";import W from"./Workflow.js";import{createWorkflowSteps as _,fetchCandidates as C}from"./workflowUtils.js";import{isGraphicForRelatableFeatureSupportedLayer as S}from"../Feature/support/featureUtils.js";var F;const U="candidate-highlight",j="esri.widgets.Editor.UpdateWorkflow",A=o.getLogger(j);let M=F=class extends W{constructor(e){super(e),this._workflowStack=new c((e=>{let t;for(t of e);return t})),this.type="update"}initialize(){const{featureFormViewModel:e}=this.data.viewModel,t=e.relatedRecordCallbacks;e.relatedRecordCallbacks={addRelatedRecord:e=>this.startCreatingRelatedRecord(e),editRelatedRecord:({relatedFeature:e})=>this.startUpdating(e),showAllRelatedRecords:t=>e.relationshipId=t.relationshipId},this.addHandles(i((()=>e.relatedRecordCallbacks=t)))}get activeEditableItem(){const{activeWorkflow:e}=this;return I(e)?e.data.editableItem:void 0}get activeWorkflow(){return this._workflowStack.last()}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditableItem?.attachmentsOnUpdateEnabled}get shouldAllowAttachmentEditing(){return!!this.activeEditableItem?.supports.includes("update")}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditableItem?.hasInvalidFormTemplate}get hasUnsupportedFields(){return!!this.activeEditableItem?.hasUnsupportedFields}get updating(){return this.updatingHandles.updating}async back(e=(()=>Promise.resolve(!0))){const{featureFormViewModel:t}=this.data.viewModel;if(null==t.relationshipId)if(this.activeWorkflow){if(this.activeWorkflow.hasPendingEdits){if(!await e())return}this.activeWorkflow.hasPreviousStep?await this.activeWorkflow.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else t.relationshipId=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e,t,a){const i=new F({data:new b({applyEditsCallback:a,viewModel:e}),onCommit:async()=>{}});return i._set("steps",this._createWorkflowSteps(i,t)),i}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e){try{const t=await this._createNestedUpdateWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:t})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");I(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?this.emit("complete"):await this._popWorkflow()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e,{addAttachmentsCallback:o,applyEditsCallback:r,viewModel:s}=this.data;if(!f(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const n=new t({sourceLayer:i,attributes:this._makeRelatedRecordAttributes(e)});return k.create({addAttachmentsCallback:o,applyEditsCallback:r,creationInfo:{layer:i,initialFeature:n,maxFeatures:1},startAt:"creating-features",viewModel:s})}async _createNestedUpdateWorkflow(e){const t=m(e.sourceLayer)?v:y,{applyEditsCallback:a,viewModel:i}=this.data,o=await t.create({feature:e,viewModel:i,applyEdits:a});return await p((()=>!o.updating)),o}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop(),o=e(i).then((()=>i.destroy()));this.updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_highlight(e){const t=this.data.viewModel.view;if(!t||!e)return;const a=e&&t.allLayerViews.items.find((({layer:t})=>t===e.layer||"subtype-sublayer"===e.layer?.type&&e.layer?.parent===t));g(a)&&this.handles.add(a.highlight(e),U)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!S(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void E("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void E("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&E("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===i));if(!s)return void E("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=t.getAttribute(s.keyField);return n||E("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field."),{[o.keyField]:n}}async _popWorkflow(){this._workflowStack.pop()?.destroy();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t="update-feature"===e.type||"create-features"===e.type;this.activeWorkflow?.exit({removeSketchHandles:t}),await e.start(),this._workflowStack.push(e);const i=await this._reconcileWorkflowStack();if(i.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",i)}async _reconcileWorkflowStack(){const e=this._workflowStack;try{const t=e.peek();return await(t?.enter()),{activeWorkflow:t,failureCount:0}}catch(t){e.pop().destroy();const{activeWorkflow:a,failureCount:i}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:i+1}}}_unhighlight(){this.handles.remove(U)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o,handles:c}=e;return _(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;let d=null;c.add(i((()=>{d=r(d)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{t.location=i.mapPoint,t.visible=!0,d?.abort();const{editableItems:r}=o.viewModel;d=new AbortController;const c=await new Promise(((e,t)=>{s(d?.signal,(()=>t(n()))),e(C(r,a,i,d?.signal))}));l(d),o.candidates=c.reduce(((e,t)=>t.error?e:[...e,...t.value]),[]),t.visible=1===o.candidates.length,0!==o.candidates.length&&(1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next())}));a.focus(),c.add(p,this.id)},async tearDown(){c.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null,c.add(u((()=>o.rootFeature),(t=>{e._unhighlight(),e._highlight(t)})),this.id)},async tearDown(){e._unhighlight(),c.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=d((async()=>{await p((()=>!e.updating)),e.previous()}));e.addHandles(u((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()})))},async tearDown(){await e.cancelAll()}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}};e([h()],M.prototype,"activeEditableItem",null),e([h()],M.prototype,"activeWorkflow",null),e([h()],M.prototype,"nestedWorkflowCount",null),e([h()],M.prototype,"shouldShowAttachments",null),e([h()],M.prototype,"shouldAllowAttachmentEditing",null),e([h()],M.prototype,"hasPendingEdits",null),e([h()],M.prototype,"helpMessage",null),e([h()],M.prototype,"reliesOnOwnerAdminPrivileges",null),e([h()],M.prototype,"hasInvalidFormTemplate",null),e([h()],M.prototype,"hasUnsupportedFields",null),e([h()],M.prototype,"updating",null),M=F=e([w(j)],M);const E=(e,t)=>A.warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature."),I=e=>!!e&&/update-/.test(e.type),R=M;export{R as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../chunks/tslib.es6.js";import r from"../../core/Accessor.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";let e=class extends r{constructor(o){super(o),this.applyEditsCallback=null,this.candidates=null,this.rootFeature=null,this.viewModel=null}};o([t()],e.prototype,"applyEditsCallback",void 0),o([t()],e.prototype,"candidates",void 0),o([t()],e.prototype,"rootFeature",void 0),o([t()],e.prototype,"viewModel",void 0),e=o([s("esri.widgets.Editor.UpdateWorkflowData")],e);const p=e;export{p as default};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";let e=class extends t{constructor(o){super(o),this.addAttachmentsCallback=null,this.applyEditsCallback=null,this.candidates=null,this.rootFeature=null,this.viewModel=null}};o([r()],e.prototype,"addAttachmentsCallback",void 0),o([r()],e.prototype,"applyEditsCallback",void 0),o([r()],e.prototype,"candidates",void 0),o([r()],e.prototype,"rootFeature",void 0),o([r()],e.prototype,"viewModel",void 0),e=o([s("esri.widgets.Editor.UpdateWorkflowData")],e);const a=e;export{a as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Graphic.js";import{createTask as t}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as i,makeHandle as r}from"../../core/handleUtils.js";import{clone as n}from"../../core/lang.js";import{throwIfAborted as a,whenOrAbort as s,eachAlways as l}from"../../core/promiseUtils.js";import{watch as o,whenOnce as c}from"../../core/reactiveUtils.js";import{px2pt as u}from"../../core/screenUtils.js";import{diff as p}from"../../core/accessorSupport/diffUtils.js";import{getDisplayFieldName as y}from"../../layers/support/fieldUtils.js";import{calculateTolerance as d}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as f}from"../../renderers/support/lengthUtils.js";import{getTransformationType as m,TransformationType as h}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as g,getSize as b}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as w,i3sPatchingEnabled as v}from"../../support/featureFlags.js";import{to3D as S}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as j}from"../../symbols/support/symbolUtils.js";import{GraphicState as I}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as U}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as V,filterGraphicHits as F}from"../../views/support/hitTestSelectUtils.js";function T(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!A(t.renderer))return{rotation:null,size:null};let i=null,r=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=g(t,e)));1===n.length&&(i=z(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&m(t)===h.RealWorldSize&&null!=b(t,e)));return 1===a.length&&(r=E(a[0],t)),{rotation:i,size:r}}function z(e,t){const i="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,r=e.field,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",s={initial:0,current:0};return{field:r,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-i*e,O((s.current+360)%360,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function x(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function L(e,t,i){if(null==t)return 0;const{symbol:r}=S(t);if(null==r||"web-style"===r.type||"cim"===r.type)return 0;const n=r.symbolLayers.at(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min($.icon,(await e(n,$.icon))[0])||$.icon}case"text":return n.size||$.text;case"line":return n.size||$.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return x(await t(n,e.scale/$.viewScaleSizeFactor),i)}case"path":return(null!=n.width?n.width:n.height)||e.scale/$.viewScaleSizeFactor;case"extrude":return n.size||e.scale/$.viewScaleSizeFactor;default:return 0}}function E(e,t){const i=e.field,r=e.axis,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",s={updating:!1,initial:0,current:0},l=f[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:i,fieldType:a,getDefault:async(e,t)=>O(o(await L(t,e,r)),a),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,O(s.current,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:re(e.valueUnit),axis:e.axis}}function O(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function A(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function k(e,t){const i=await j(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t});null!=p(e.symbol,i)&&(e.symbol=i)}function G(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function M(e,t,n,a){await R(e,t,a);const s=e.on("create",(async i=>{if("cancel"===i.state)return R(e,t,a);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await k(e,a),n(e)}}));return i([s,r((()=>e.cancel()))])}async function R(e,t,i){const r=t.layer,n={...t.template.prototype.attributes};await C(e,r,n,i),e.layer.elevationInfo=r.elevationInfo,await e.create(G(r.geometryType),{graphicProperties:{attributes:n,sourceLayer:r},hasZ:r.capabilities.data.supportsZ,geometryToPlace:t.geometryToPlace??void 0})}async function C(t,i,r,n){const a=new e({sourceLayer:i,attributes:r}),{rotation:s,size:l}=T(a);let o=await j(a,{useSourceLayer:!0,webStyleCache:n}),c=!1;for(const e of[l,s]){if(null==e)continue;null==r[e.field]&&(r[e.field]=await e.getDefault(o,t.view),c=!0)}switch(c&&(o=await j(a,{useSourceLayer:!0,webStyleCache:n})),o?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=o;break;case"simple-line":case"line-3d":t.polylineSymbol=o;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=o}P(t.tooltipOptions,l,s)}function P(e,t,i){e.visualVariables=null!=t||null!=i?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=i?{valueType:i.fieldType,rotationType:i.rotationType??"geographic"}:null}:null}function D(e,t){return e?e.find((e=>e.layer===t)):void 0}async function q(e,t,i,r){if(0===e.length)return[];const{updatable:n,graphicsByLayer:a}=await i.async((async()=>{const{results:n}=await s(V(t,i),r),a=new Map,l=e=>{const t=e.layer,i=a.get(t);if(!i){const e=new Array;return a.set(t,e),e}return i};F(n).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&a.has(t)));return 0!==o.length&&i.stopPropagation(),{updatable:o,graphicsByLayer:a}}));return s(l(n.map((async({layer:e})=>{const{objectIdField:t}=e,i="displayField"in e?e.displayField:null,n=[t];null!=i&&e.fieldsIndex.has(i)&&n.push(i);const s=a.get(e);if(!!s.some((e=>n.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=n,t.returnGeometry=!1,t.objectIds=s.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:r}).then((({features:e})=>e))}return s}))),r)}async function Z(e,t,i,r){if(0===e.length)return[];let n=null;const a=await i.async((async()=>{const{results:a}=await s(t.hitTest(i),r);if(0===a.length)return[];const l=new Set;n=F(a),n.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:i})=>l.has(e)&&(t.includes("update")||t.includes("delete")||i)));return o.length>0&&i.stopPropagation(),o}));return s(l(a.map((({layer:e})=>{const a=e.objectIdField,s="displayField"in e?e.displayField:null,l=y({displayField:s,fields:e.fields}),o=[a];null!=l&&e.fieldsIndex.has(l)&&o.push(l);const c=e.createQuery();c.outFields=o,c.returnGeometry=!1;const u="renderer"in e?d({renderer:e.renderer,event:i}):0;return c.geometry=U(i.mapPoint,u,t),c.outSpatialReference=t.spatialReference,e.queryFeatures(c,{signal:r}).then((({features:t})=>(n?.forEach((({graphic:i})=>{i.layer!==e||t.some((e=>e.getObjectId()===i.getObjectId()))||t.push(i)})),t)))}))),r)}async function Q(e,t,i,r){switch(t.type){case"3d":return q(e,t,i,r);case"2d":return Z(e,t,i,r)}}async function B(e,t,i){const{sourceLayer:r}=e,n=r.createQuery();n.objectIds=[e.getAttribute(r.objectIdField)],n.outFields=["*"],n.outSpatialReference=t,n.returnM=r.capabilities.data.supportsM,n.returnZ=r.capabilities.data.supportsZ,w()&&v()&&"scene"===r.type&&null!=r.infoFor3D&&(n.returnGeometry=!0,n.formatOf3DObjects="3D_glb");const s=await r.queryFeatures(n,{signal:i});a(i);return s.features[0]}async function W(e,t,i,r,n){let a=!1;const{rotation:s,size:l}=r;[s,l].forEach((async i=>{if(null==i)return;const r=t.getAttribute(i.field);if(null!=r)i.initValue(r);else{const r=await i.getDefault(t.symbol,e.view);i.initValue(r),t.setAttribute(i.field,r),a=!0}})),a&&await k(t,n);const o={multipleSelectionEnabled:!1};return"point"===i.geometryType&&(o.enableRotation=null!=s,o.enableScaling=null!=l),P(e.tooltipOptions,l,s),e.layer.elevationInfo=i.elevationInfo,e.update(t,o)}function _(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function H(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function J(e,t,i,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=r.rotation,s=_(i.toolEventInfo);if(null!=a&&null!=s)if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.initValue();else{a.isUpdatingInteractively=!0;const{field:i,getValue:r}=a;t.setAttribute(i,r(s.angle,e))}const l=r.size,o=H(i.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:i,getValue:r}=l;t.setAttribute(i,r(o.xScale,e))}await k(t,n)}async function K(e,t,n,a,s,l){const c=pe(e);await k(c,l),a.map.add(n.layer),n.layer.add(c);const u=e.sourceLayer,p=le(a,u);await Y(a,c),await W(n,c,u,t,l);const y=N(n,e,c);let d=null;p.then((e=>d=e)).catch((()=>{}));const f=t.size,m=t.rotation,h=o((()=>e.attributes),(async e=>{let t=!1;for(const i in e){const r=e[i];r!==c.getAttribute(i)&&(c.setAttribute(i,r),null==f||f.isUpdatingInteractively||f.field!==i||f.initValue(r),null==m||m.isUpdatingInteractively||m.field!==i||m.initValue(r),(null==d||d.requiredFields.includes(i))&&(t=!0))}t&&await k(c,l)})),g=n.on("update",(async e=>{const i=e.graphics[0];if("complete"===e.state)return W(n,i,u,t,l);await J(a,i,e,t,l),s(pe(i),e)})),b=n.on(["undo","redo"],(async e=>{s(pe(e.graphics[0]),e)})),w=n.updateOnGraphicClick;return{visual:i([y,r((()=>{n.updateOnGraphicClick=!1}))]),interactive:i([b,g,r((()=>n.cancel())),h,r((()=>{n.updateOnGraphicClick=w}))])}}function N(e,n,s){const l=e.view,o=n.sourceLayer,u=n.layer,p=n.getAttribute(u.objectIdField);let y=null;function d(e){y?.abort(),y=t((async t=>{const i=await le(l,o);a(t),i.setVisibility?.(p,e)}))}return d(!1),i([X(l,s,(e=>d(!e))),r((async()=>{d(!0);const t=await le(l,o);await c((()=>!t.updating)),e.layer.remove(s)}))])}function X(e,t,r){if("3d"===e.type){const n=new I({graphic:t});return i([e.trackGraphicState(n),o((()=>n.displaying),r)])}return o((()=>t.visible),r)}async function Y(e,t){if("3d"===e.type){const i=new I({graphic:t}),r=e.trackGraphicState(i);await c((()=>i.displaying)),r.remove()}else await c((()=>t.visible))}const $={icon:u(24),text:u(12),line:u(1),viewScaleSizeFactor:100};function ee(e,t,i){let r=!1;return e.filter((e=>!!r||(r=e===t,r))).map((e=>i[e]()))}function te(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function ie(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const i=te(e.viewModel.featureTemplatesViewModel.items);null==i||i.supportsUpload||(e.creationInfo=i,t.shift())}return t}function re(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function ne(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ae(e){const{creationInfo:t,viewModel:i}=e;if(!t)return!1;const{layer:r}=t,n=i.editableItems.find((e=>e.layer===r));if(n)return n.attachmentsOnCreateEnabled;const a=r.capabilities?.data,s=i.layerInfos?.find((e=>e.layer===r));return!(!(a&&"supportsAttachment"in a&&a.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const se=e=>/-stop/.test(e)||/vertex-/.test(e),le=(e,t)=>{const i="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(i)};function oe(e){return"createInteractiveEditSession"in e}const ce=Symbol();function ue(e){return e&&"object"==typeof e&&ce in e}function pe(e){const t=e.geometry;if("mesh"===t?.type){const i=e.cloneShallow();return i.attributes=n(e.attributes),i.geometry=t.cloneShallow(),i.geometry.transform=t.transform?.clone()??null,i}return e.clone()}function ye(e){const t=e.cursor;return e.cursor="progress",r((()=>e.cursor=t))}export{ce as UsesSketchViewModelSymbol,ie as avoidFeatureTemplateSelectionWithOnlyOneItem,oe as canCreateInteractiveEditSession,pe as cloneGraphicExceptMesh,ee as createWorkflowSteps,Q as fetchCandidates,B as fetchFullFeature,D as findLayerInfo,T as getVisualVariableAttributes,se as isTerminalUpdateEventType,ne as prepareAttachmentsForCreateWorkflow,M as setUpFeatureAdd,K as setUpGeometryUpdate,ae as shouldShowAttachmentsForCreateWorkflow,ye as showProgressCursor,$ as sizeDefaults,re as sizeVariableUnitToLengthUnit,R as startCreatingNewFeature,W as startUpdatingFeature,k as updateGraphicSymbolWhenRequired,J as visualVariableInteractiveUpdate,le as whenEditorLayerView,Y as whenGraphicDisplayed,ue as workflowUsesSketchViewModel};
5
+ import e from"../../Graphic.js";import{createTask as t}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as i,makeHandle as r}from"../../core/handleUtils.js";import{clone as n}from"../../core/lang.js";import{throwIfAborted as a,whenOrAbort as s,eachAlways as l}from"../../core/promiseUtils.js";import{watch as o,whenOnce as c}from"../../core/reactiveUtils.js";import{px2pt as u}from"../../core/screenUtils.js";import{diff as p}from"../../core/accessorSupport/diffUtils.js";import{getDisplayFieldName as y}from"../../layers/support/fieldUtils.js";import{calculateTolerance as d}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as f}from"../../renderers/support/lengthUtils.js";import{getTransformationType as m,TransformationType as h}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as g,getSize as b}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as w,i3sPatchingEnabled as v}from"../../support/featureFlags.js";import{to3D as S}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as j}from"../../symbols/support/symbolUtils.js";import{GraphicState as I}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as U}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as V,filterGraphicHits as F}from"../../views/support/hitTestSelectUtils.js";function L(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!O(t.renderer))return{rotation:null,size:null};let i=null,r=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=g(t,e)));1===n.length&&(i=T(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&m(t)===h.RealWorldSize&&null!=b(t,e)));return 1===a.length&&(r=k(a[0],t)),{rotation:i,size:r}}function T(e,t){const i="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,r=e.field,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",s={initial:0,current:0};return{field:r,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-i*e,E((s.current+360)%360,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function z(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function x(e,t,i){if(null==t)return 0;const{symbol:r}=S(t);if(null==r||"web-style"===r.type||"cim"===r.type)return 0;const n=r.symbolLayers.at(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min($.icon,(await e(n,$.icon))[0])||$.icon}case"text":return n.size||$.text;case"line":return n.size||$.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return z(await t(n,e.scale/$.viewScaleSizeFactor),i)}case"path":return(null!=n.width?n.width:n.height)||e.scale/$.viewScaleSizeFactor;case"extrude":return n.size||e.scale/$.viewScaleSizeFactor;default:return 0}}function k(e,t){const i=e.field,r=e.axis,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",s={updating:!1,initial:0,current:0},l=f[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:i,fieldType:a,getDefault:async(e,t)=>E(o(await x(t,e,r)),a),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,E(s.current,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:re(e.valueUnit),axis:e.axis}}function E(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function O(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function A(e,t){const i=await j(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t});null!=p(e.symbol,i)&&(e.symbol=i)}function M(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function C(e,t,n,a){await G(e,t,a);const s=e.on("create",(async i=>{if("cancel"===i.state)return G(e,t,a);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template?.prototype.attributes}),await A(e,a),n(e)}}));return i([s,r((()=>e.cancel()))])}async function G(e,t,i){const r=t.layer,n={...t.template?.prototype.attributes};await R(e,r,n,i),e.layer.elevationInfo=r.elevationInfo,await e.create(M(r.geometryType),{graphicProperties:{attributes:n,sourceLayer:r},hasZ:r.capabilities.data.supportsZ,geometryToPlace:t.geometryToPlace??void 0})}async function R(t,i,r,n){const a=new e({sourceLayer:i,attributes:r}),{rotation:s,size:l}=L(a);let o=await j(a,{useSourceLayer:!0,webStyleCache:n}),c=!1;for(const e of[l,s]){if(null==e)continue;null==r[e.field]&&(r[e.field]=await e.getDefault(o,t.view),c=!0)}switch(c&&(o=await j(a,{useSourceLayer:!0,webStyleCache:n})),o?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=o;break;case"simple-line":case"line-3d":t.polylineSymbol=o;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=o}P(t.tooltipOptions,l,s)}function P(e,t,i){e.visualVariables=null!=t||null!=i?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=i?{valueType:i.fieldType,rotationType:i.rotationType??"geographic"}:null}:null}function D(e,t){return e?e.find((e=>e.layer===t)):void 0}async function q(e,t,i,r){if(0===e.length)return[];const{updatable:n,graphicsByLayer:a}=await i.async((async()=>{const{results:n}=await s(V(t,i),r),a=new Map,l=e=>{const t=e.layer,i=a.get(t);if(!i){const e=new Array;return a.set(t,e),e}return i};F(n).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&a.has(t)));return 0!==o.length&&i.stopPropagation(),{updatable:o,graphicsByLayer:a}}));return s(l(n.map((async({layer:e})=>{const{objectIdField:t}=e,i="displayField"in e?e.displayField:null,n=[t];null!=i&&e.fieldsIndex.has(i)&&n.push(i);const s=a.get(e);if(!!s.some((e=>n.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=n,t.returnGeometry=!1,t.objectIds=s.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:r}).then((({features:e})=>e))}return s}))),r)}async function Z(e,t,i,r){if(0===e.length)return[];let n=null;const a=await i.async((async()=>{const{results:a}=await s(t.hitTest(i),r);if(0===a.length)return[];const l=new Set;n=F(a),n.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:i})=>l.has(e)&&(t.includes("update")||t.includes("delete")||i)));return o.length>0&&i.stopPropagation(),o}));return s(l(a.map((({layer:e})=>{const a=e.objectIdField,s="displayField"in e?e.displayField:null,l=y({displayField:s,fields:e.fields}),o=[a];null!=l&&e.fieldsIndex.has(l)&&o.push(l);const c=e.createQuery();c.outFields=o,c.returnGeometry=!1;const u="renderer"in e?d({renderer:e.renderer,event:i}):0;return c.geometry=U(i.mapPoint,u,t),c.outSpatialReference=t.spatialReference,e.queryFeatures(c,{signal:r}).then((({features:t})=>(n?.forEach((({graphic:i})=>{i.layer!==e||t.some((e=>e.getObjectId()===i.getObjectId()))||t.push(i)})),t)))}))),r)}async function Q(e,t,i,r){switch(t.type){case"3d":return q(e,t,i,r);case"2d":return Z(e,t,i,r)}}async function B(e,t,i){const{sourceLayer:r}=e,n=r.createQuery();n.objectIds=[e.getAttribute(r.objectIdField)],n.outFields=["*"],n.outSpatialReference=t,n.returnM=r.capabilities.data.supportsM,n.returnZ=r.capabilities.data.supportsZ,w()&&v()&&"scene"===r.type&&null!=r.infoFor3D&&(n.returnGeometry=!0,n.formatOf3DObjects="3D_glb");const s=await r.queryFeatures(n,{signal:i});a(i);return s.features[0]}async function W(e){const{graphic:t,sketchViewModel:i,sourceLayer:r,visualVariables:n,webStyleCache:a}=e;let s=!1;const{rotation:l,size:o}=n;[l,o].forEach((async e=>{if(null==e)return;const r=t.getAttribute(e.field);if(null!=r)e.initValue(r);else{const r=await e.getDefault(t.symbol,i.view);e.initValue(r),t.setAttribute(e.field,r),s=!0}})),s&&await A(t,a);const c={multipleSelectionEnabled:!1};return"point"===r.geometryType&&(c.enableRotation=null!=l,c.enableScaling=null!=o),P(i.tooltipOptions,o,l),i.layer.elevationInfo=r.elevationInfo,i.update(t,c)}function _(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function H(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function J(e,t,i,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=r.rotation,s=_(i.toolEventInfo);if(null!=a&&null!=s)if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.initValue();else{a.isUpdatingInteractively=!0;const{field:i,getValue:r}=a;t.setAttribute(i,r(s.angle,e))}const l=r.size,o=H(i.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:i,getValue:r}=l;t.setAttribute(i,r(o.xScale,e))}await A(t,n)}async function K(e,t,n,a,s,l){const c=pe(e);await A(c,l),a.map.add(n.layer),n.layer.add(c);const u=e.sourceLayer,p=le(a,u);await Y(a,c),await W({graphic:c,sketchViewModel:n,sourceLayer:u,visualVariables:t,webStyleCache:l});const y=N(n,e,c);let d=null;p.then((e=>d=e)).catch((()=>{}));const f=t.size,m=t.rotation,h=o((()=>e.attributes),(async e=>{let t=!1;for(const i in e){const r=e[i];r!==c.getAttribute(i)&&(c.setAttribute(i,r),null==f||f.isUpdatingInteractively||f.field!==i||f.initValue(r),null==m||m.isUpdatingInteractively||m.field!==i||m.initValue(r),(null==d||d.requiredFields.includes(i))&&(t=!0))}t&&await A(c,l)})),g=n.on("update",(async e=>{const i=e.graphics[0];if("complete"===e.state)return W({graphic:i,sketchViewModel:n,sourceLayer:u,visualVariables:t,webStyleCache:l});await J(a,i,e,t,l),s(pe(i),e)})),b=n.on(["undo","redo"],(async e=>{s(pe(e.graphics[0]),e)})),w=n.updateOnGraphicClick;return{visual:i([y,r((()=>{n.updateOnGraphicClick=!1}))]),interactive:i([b,g,r((()=>n.cancel())),h,r((()=>{n.updateOnGraphicClick=w}))])}}function N(e,n,s){const l=e.view,o=n.sourceLayer,u=n.layer,p=n.getAttribute(u.objectIdField);let y=null;function d(e){y?.abort(),y=t((async t=>{const i=await le(l,o);a(t),i.setVisibility?.(p,e)}))}return d(!1),i([X(l,s,(e=>d(!e))),r((async()=>{d(!0);const t=await le(l,o);await c((()=>!t.updating)),e.layer.remove(s)}))])}function X(e,t,r){if("3d"===e.type){const n=new I({graphic:t});return i([e.trackGraphicState(n),o((()=>n.displaying),r)])}return o((()=>t.visible),r)}async function Y(e,t){if("3d"===e.type){const i=new I({graphic:t}),r=e.trackGraphicState(i);await c((()=>i.displaying)),r.remove()}else await c((()=>t.visible))}const $={icon:u(24),text:u(12),line:u(1),viewScaleSizeFactor:100};function ee(e,t,i){let r=!1;return e.filter((e=>!!r||(r=e===t,r))).map((e=>i[e]()))}function te(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function ie(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const i=te(e.viewModel.featureTemplatesViewModel.items);null==i||i.supportsUpload||(e.creationInfo=i,t.shift())}return t}function re(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function ne(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ae(e){const{creationInfo:t,viewModel:i}=e;if(!t)return!1;const{layer:r}=t,n=i.editableItems.find((e=>e.layer===r));if(n)return n.attachmentsOnCreateEnabled;const a=r.capabilities?.data,s=i.layerInfos?.find((e=>e.layer===r));return!(!(a&&"supportsAttachment"in a&&a.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const se=e=>/-stop/.test(e)||/vertex-/.test(e),le=(e,t)=>{const i="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(i)};function oe(e){return"createInteractiveEditSession"in e}const ce=Symbol();function ue(e){return e&&"object"==typeof e&&ce in e}function pe(e){const t=e.geometry;if("mesh"===t?.type){const i=e.cloneShallow();return i.attributes=n(e.attributes),i.geometry=t.cloneShallow(),i.geometry.transform=t.transform?.clone()??null,i}return e.clone()}function ye(e){const t=e.cursor;return e.cursor="progress",r((()=>e.cursor=t))}export{ce as UsesSketchViewModelSymbol,ie as avoidFeatureTemplateSelectionWithOnlyOneItem,oe as canCreateInteractiveEditSession,pe as cloneGraphicExceptMesh,ee as createWorkflowSteps,Q as fetchCandidates,B as fetchFullFeature,D as findLayerInfo,L as getVisualVariableAttributes,se as isTerminalUpdateEventType,ne as prepareAttachmentsForCreateWorkflow,C as setUpFeatureAdd,K as setUpGeometryUpdate,ae as shouldShowAttachmentsForCreateWorkflow,ye as showProgressCursor,$ as sizeDefaults,re as sizeVariableUnitToLengthUnit,G as startCreatingNewFeature,W as startUpdatingFeature,A as updateGraphicSymbolWhenRequired,J as visualVariableInteractiveUpdate,le as whenEditorLayerView,Y as whenGraphicDisplayed,ue as workflowUsesSketchViewModel};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{formatDate as r,formatTimestamp as n,formatTimeOnly as i,formatDateOnly as o,convertDateFormatToIntlOptions as a}from"../../../intl/date.js";import{formatNumber as l,convertNumberFormatToIntlOptions as u}from"../../../intl/number.js";import{isRasterPixelValueField as s,featureHasFields as f}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as c,getEffectiveLayerCapabilities as d}from"../../../layers/support/layerUtils.js";import p from"../../../popup/support/FieldInfoFormat.js";import{loadArcade as y}from"../../../support/arcadeOnDemand.js";const m="esri.widgets.Feature.support.featureUtils",g=e.getLogger(m),h=/href=(""|'')/gi,I=/(\{([^\{\r\n]+)\})/g,b=/\'/g,F=/^\s*expression\//i,w=/(\n)/gi,N=/[\u00A0-\u9999<>\&]/gim,j=/href\s*=\s*(?:\"([^\"]+)\"|\'([^\']+)\')/gi,E=/^(?:mailto:|tel:)/,T="relationships/",x=a("short-date-short-time");function C(e){if(null!=e)return e.get("sourceLayer")||e.get("layer")}async function q(e,t){return"function"==typeof e?e(t):e}function A(e=""){if(e)return!E.test(e.trim().toLowerCase())}function M(e){return!!e&&F.test(e)}function R(e,t){if(!M(t)||!e)return null;const r=t.replace(F,"").toLowerCase();let n=null;return e.some((e=>e.name.toLowerCase()===r&&(n=e,!0))),n}function D(e,t){const r=R(t,e?.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function v(e,t){const r=t.get(e.toLowerCase());return`{${r&&r.fieldName||e}}`}function L(e){return e.replaceAll(h,"")}function U(e,t){const r=O(t,e);return r?r.name:e}function $(e,t){return e&&e.map((e=>U(e,t)))}function O(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function S(e){return`${e}`.trim()}function G({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?k({formattedAttributes:t,template:H(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function k({formattedAttributes:e,template:r,fieldInfoMap:n}){return S(L(t(t(r,(e=>v(e,n))),e)))}function P(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replaceAll(b,i);t[e]=o}}function Q(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>P(e,r,t))),r}function _(e,r,n){const i=(r=S(r))&&"{"!==r[0];return t(e,Q(n,i||!1))}function z(e,t){return e.replaceAll(I,((e,r,n)=>{const i=O(t,n);return i?`{${i.name}}`:r}))}function H(e,t,r){const n=z(e,r);return n?n.replaceAll(j,((e,r,n)=>_(e,r||n,t))):n}function V(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 Z(e){return null!=e&&"object"==typeof e&&"layer"in e&&!!e.layer}function B(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-image"===e.type}function J(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&&"when"in e}function K(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 W(e){return J(e)&&K(e)}function X(e,t){const{fieldInfos:r,fieldName:n,preventPlacesFormatting:i,layer:o}=t,a=Y(r,n),f=a?.clone(),d=O(o,n);if(f&&!s(n)){const t=d?.type;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t){const r=f.format??new p;if(r.dateFormat??="date-only"===t?"short-date":"short-date-short-time","number"==typeof e){const t=!Z(o)&&c(o)&&o.datesInUnknownTimezone||Z(o)&&B(o.layer)&&o.layer.datesInUnknownTimezone;return r.formatDate(e,t)}switch(t){case"date-only":return r.formatDateOnly(e);case"time-only":return r.formatTimeOnly(e);case"timestamp-offset":return r.formatTimestamp(e)}}}const y=f?.format;return"string"==typeof e&&s(n)&&y?y.formatRasterPixelValue(e):"string"==typeof(e=V(e,y))||null==e||null==y?ae(e):i?l(e,{...u(y),minimumFractionDigits:0,maximumFractionDigits:20}):y.formatNumber(e)}function Y(e,t){if(e&&e.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function ee({fieldName:e,graphic:t,layer:r}){if(de(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function te({fieldName:e,value:t,graphic:r,layer:n}){if(de(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=r&&n.getFieldDomain(e,{feature:r});return i&&"coded-value"===i.type?i.getName(t):null}function re(e,t){const{creatorField:n,creationDateField:i,editorField:o,editDateField:a}=e;if(!t)return;const l=t[a];if("number"==typeof l){const e=t[o];return{type:"edit",date:r(l,x),user:e}}const u=t[i];if("number"==typeof u){const e=t[n];return{type:"create",date:r(u,x),user:e}}return null}function ne(e,t){const r=new Map;return e?(e.forEach((e=>{const n=U(e.fieldName,t);e.fieldName=n,r.set(n.toLowerCase(),e)})),r):r}function ie(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e&&e.fieldInfos;r&&t.push(...r)}})),t):t}function oe(e){return e.replaceAll(N,(e=>`&#${e.charCodeAt(0)};`))}function ae(e){return"string"==typeof e?e.replaceAll(w,'<br class="esri-text-new-line" />'):e}function le(e){const{value:t,fieldName:a,fieldInfos:l,fieldInfoMap:u,layer:s,graphic:f}=e;if(null==t)return"";const c=te({fieldName:a,value:t,graphic:f,layer:s});if(c)return c;const d=ee({fieldName:a,graphic:f,layer:s});if(d)return d;if(u.get(a.toLowerCase()))return X(t,{fieldInfos:l||Array.from(u.values()),fieldName:a,layer:s});switch(s?.fieldsIndex?.get(a)?.type){case"date":return r(t);case"date-only":return o(t);case"time-only":return i(t);case"timestamp-offset":return n(t)}return ae(t)}function ue({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o}){const a={};return o?.forEach((t=>me({attributes:a,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r}))),t&&Object.keys(t).forEach((o=>{const l=t[o];a[o]=le({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:l,graphic:n})})),a}async function se(e,t){const{layer:r,graphic:n,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:r,graphic:n,objectId:u,requiredFields:i};return g.warn(e,t),null}if(!d(r)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:r,graphic:n,requiredFields:i,returnGeometry:a};return g.warn(e,t),null}const s=r.createQuery();s.objectIds=o,s.outFields=i?.length?i:[r.objectIdField],s.returnGeometry=!!a,s.returnZ=!!a,s.returnM=!!a,s.outSpatialReference=l;return(await r.queryFeatures(s,t)).features[0]}async function fe(e){if(!e.expressionInfos?.length)return!1;const t=await y(),{arcadeUtils:{hasGeometryFunctions:r}}=t;return r(e)}async function ce({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=e.attributes[r.objectIdField];if(null==o)return;const a=[o],l=await t.getRequiredFields(r.fieldsIndex),u=f(l,e),s=u?[]:l,c=t.returnGeometry||await fe(t);if(u&&!c)return;const d=await se({layer:r,graphic:e,outFields:s,objectIds:a,returnGeometry:c,spatialReference:n},i);d&&(d.geometry&&(e.geometry=d.geometry),d.attributes&&(e.attributes={...e.attributes,...d.attributes}))}function de(e=""){return!!e&&e.includes(T)}function pe(e){return e?`${T}${e.layerId}/${e.fieldName}`:""}function ye({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o}){e&&t&&r&&Object.keys(t.attributes).forEach((a=>{const l=pe({layerId:r.relation.id.toString(),fieldName:a}),u=t.attributes[a];e[l]=le({fieldName:l,fieldInfos:n,fieldInfoMap:i,layer:o,value:u,graphic:t})}))}function me({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}){e&&t&&(t.relatedFeatures&&t.relatedFeatures&&t.relatedFeatures.forEach((o=>ye({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))),t.relatedStatsFeatures&&t.relatedStatsFeatures&&t.relatedStatsFeatures.forEach((o=>ye({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},he=({layer:e,method:t,query:r,definitionExpression:n})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=r.where?r.where:null,o=null!=r.geometry?r.geometry:null;ge(n)||ge(i)||"extent"===o?.type||"tile"===r.resultType||(r.cacheHint=!0)},Ie=({query:e,layer:t,method:r})=>{he({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})},be=({queryPayload:e,layer:t,method:r})=>{he({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})};function Fe(e,t,r){return e&&t&&r?we(e.allLayers,t,r)||we(e.allTables,t,r):null}function we(e,t,r){return e.filter(W).find((e=>e!==t&&e.url===t.url&&e.layerId===r.relatedTableId))}export{ae as applyTextFormattingHTML,ne as createfieldInfoMap,Fe as findRelatedLayer,z as fixTokens,ue as formatAttributes,re as formatEditInfo,X as formatValueToFieldInfo,ie as getAllFieldInfos,Y as getFieldInfo,D as getFieldInfoLabel,U as getFixedFieldName,$ as getFixedFieldNames,C as getSourceLayer,q as graphicCallback,oe as htmlEntities,M as isExpressionField,J as isFeatureSupportedLayer,W as isRelatableFeatureSupportedLayer,K as isRelatableLayer,de as isRelatedField,Ie as preLayerQueryCallback,be as preRequestCallback,se as querySourceLayer,ce as queryUpdatedFeature,A as shouldOpenInNewTab,k as substituteAttributes,G as substituteFieldsInLinksAndAttributes};
5
+ import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{formatDate as r,formatTimestamp as n,formatTimeOnly as i,formatDateOnly as o,convertDateFormatToIntlOptions as a}from"../../../intl/date.js";import{formatNumber as l,convertNumberFormatToIntlOptions as u}from"../../../intl/number.js";import{isRasterPixelValueField as s,featureHasFields as f}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as c,getEffectiveLayerCapabilities as d}from"../../../layers/support/layerUtils.js";import p from"../../../popup/support/FieldInfoFormat.js";import{loadArcade as y}from"../../../support/arcadeOnDemand.js";const m="esri.widgets.Feature.support.featureUtils",g=e.getLogger(m),h=/href=(""|'')/gi,I=/(\{([^\{\r\n]+)\})/g,b=/\'/g,F=/^\s*expression\//i,w=/(\n)/gi,N=/[\u00A0-\u9999<>\&]/gim,j=/href\s*=\s*(?:\"([^\"]+)\"|\'([^\']+)\')/gi,E=/^(?:mailto:|tel:)/,T="relationships/",x=a("short-date-short-time");function C(e){if(null!=e)return e.get("sourceLayer")||e.get("layer")}async function q(e,t){return"function"==typeof e?e(t):e}function A(e=""){if(e)return!E.test(e.trim().toLowerCase())}function M(e){return!!e&&F.test(e)}function R(e,t){if(!M(t)||!e)return null;const r=t.replace(F,"").toLowerCase();let n=null;return e.some((e=>e.name.toLowerCase()===r&&(n=e,!0))),n}function L(e,t){const r=R(t,e?.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function D(e,t){const r=t.get(e.toLowerCase());return`{${r&&r.fieldName||e}}`}function v(e){return e.replaceAll(h,"")}function U(e,t){const r=O(t,e);return r?r.name:e}function $(e,t){return e&&e.map((e=>U(e,t)))}function O(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function S(e){return`${e}`.trim()}function G({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?k({formattedAttributes:t,template:H(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function k({formattedAttributes:e,template:r,fieldInfoMap:n}){return S(v(t(t(r,(e=>D(e,n))),e)))}function P(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replaceAll(b,i);t[e]=o}}function Q(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>P(e,r,t))),r}function _(e,r,n){const i=(r=S(r))&&"{"!==r[0];return t(e,Q(n,i||!1))}function z(e,t){return e.replaceAll(I,((e,r,n)=>{const i=O(t,n);return i?`{${i.name}}`:r}))}function H(e,t,r){const n=z(e,r);return n?n.replaceAll(j,((e,r,n)=>_(e,r||n,t))):n}function V(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 Z(e){return null!=e&&"object"==typeof e&&"layer"in e&&!!e.layer}function B(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-image"===e.type}function J(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&&"when"in e}function K(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 W(e){return J(e)&&K(e)}function X(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&W(e.sourceLayer)}function Y(e,t){const{fieldInfos:r,fieldName:n,preventPlacesFormatting:i,layer:o}=t,a=ee(r,n),f=a?.clone(),d=O(o,n);if(f&&!s(n)){const t=d?.type;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t){const r=f.format??new p;if(r.dateFormat??="date-only"===t?"short-date":"short-date-short-time","number"==typeof e){const t=!Z(o)&&c(o)&&o.datesInUnknownTimezone||Z(o)&&B(o.layer)&&o.layer.datesInUnknownTimezone;return r.formatDate(e,t)}switch(t){case"date-only":return r.formatDateOnly(e);case"time-only":return r.formatTimeOnly(e);case"timestamp-offset":return r.formatTimestamp(e)}}}const y=f?.format;return"string"==typeof e&&s(n)&&y?y.formatRasterPixelValue(e):"string"==typeof(e=V(e,y))||null==e||null==y?le(e):i?l(e,{...u(y),minimumFractionDigits:0,maximumFractionDigits:20}):y.formatNumber(e)}function ee(e,t){if(e&&e.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function te({fieldName:e,graphic:t,layer:r}){if(pe(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function re({fieldName:e,value:t,graphic:r,layer:n}){if(pe(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=r&&n.getFieldDomain(e,{feature:r});return i&&"coded-value"===i.type?i.getName(t):null}function ne(e,t){const{creatorField:n,creationDateField:i,editorField:o,editDateField:a}=e;if(!t)return;const l=t[a];if("number"==typeof l){const e=t[o];return{type:"edit",date:r(l,x),user:e}}const u=t[i];if("number"==typeof u){const e=t[n];return{type:"create",date:r(u,x),user:e}}return null}function ie(e,t){const r=new Map;return e?(e.forEach((e=>{const n=U(e.fieldName,t);e.fieldName=n,r.set(n.toLowerCase(),e)})),r):r}function oe(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e&&e.fieldInfos;r&&t.push(...r)}})),t):t}function ae(e){return e.replaceAll(N,(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:a,fieldInfos:l,fieldInfoMap:u,layer:s,graphic:f}=e;if(null==t)return"";const c=re({fieldName:a,value:t,graphic:f,layer:s});if(c)return c;const d=te({fieldName:a,graphic:f,layer:s});if(d)return d;if(u.get(a.toLowerCase()))return Y(t,{fieldInfos:l||Array.from(u.values()),fieldName:a,layer:s});switch(s?.fieldsIndex?.get(a)?.type){case"date":return r(t);case"date-only":return o(t);case"time-only":return i(t);case"timestamp-offset":return n(t)}return le(t)}function se({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o}){const a={};return o?.forEach((t=>ge({attributes:a,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r}))),t&&Object.keys(t).forEach((o=>{const l=t[o];a[o]=ue({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:l,graphic:n})})),a}async function fe(e,t){const{layer:r,graphic:n,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:r,graphic:n,objectId:u,requiredFields:i};return g.warn(e,t),null}if(!d(r)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:r,graphic:n,requiredFields:i,returnGeometry:a};return g.warn(e,t),null}const s=r.createQuery();s.objectIds=o,s.outFields=i?.length?i:[r.objectIdField],s.returnGeometry=!!a,s.returnZ=!!a,s.returnM=!!a,s.outSpatialReference=l;return(await r.queryFeatures(s,t)).features[0]}async function ce(e){if(!e.expressionInfos?.length)return!1;const t=await y(),{arcadeUtils:{hasGeometryFunctions:r}}=t;return r(e)}async function de({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=e.attributes[r.objectIdField];if(null==o)return;const a=[o],l=await t.getRequiredFields(r.fieldsIndex),u=f(l,e),s=u?[]:l,c=t.returnGeometry||await ce(t);if(u&&!c)return;const d=await fe({layer:r,graphic:e,outFields:s,objectIds:a,returnGeometry:c,spatialReference:n},i);d&&(d.geometry&&(e.geometry=d.geometry),d.attributes&&(e.attributes={...e.attributes,...d.attributes}))}function pe(e=""){return!!e&&e.includes(T)}function ye(e){return e?`${T}${e.layerId}/${e.fieldName}`:""}function me({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o}){e&&t&&r&&Object.keys(t.attributes).forEach((a=>{const l=ye({layerId:r.relation.id.toString(),fieldName:a}),u=t.attributes[a];e[l]=ue({fieldName:l,fieldInfos:n,fieldInfoMap:i,layer:o,value:u,graphic:t})}))}function ge({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}){e&&t&&(t.relatedFeatures&&t.relatedFeatures&&t.relatedFeatures.forEach((o=>me({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))),t.relatedStatsFeatures&&t.relatedStatsFeatures&&t.relatedStatsFeatures.forEach((o=>me({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))))}const he=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:r,definitionExpression:n})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=r.where?r.where:null,o=null!=r.geometry?r.geometry:null;he(n)||he(i)||"extent"===o?.type||"tile"===r.resultType||(r.cacheHint=!0)},be=({query:e,layer:t,method:r})=>{Ie({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})},Fe=({queryPayload:e,layer:t,method:r})=>{Ie({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})};function we(e,t,r){return e&&t&&r?Ne(e.allLayers,t,r)||Ne(e.allTables,t,r):null}function Ne(e,t,r){return e.filter(W).find((e=>e!==t&&e.url===t.url&&e.layerId===r.relatedTableId))}export{le as applyTextFormattingHTML,ie as createfieldInfoMap,we as findRelatedLayer,z as fixTokens,se as formatAttributes,ne as formatEditInfo,Y as formatValueToFieldInfo,oe as getAllFieldInfos,ee as getFieldInfo,L as getFieldInfoLabel,U as getFixedFieldName,$ as getFixedFieldNames,C as getSourceLayer,q as graphicCallback,ae as htmlEntities,M as isExpressionField,J as isFeatureSupportedLayer,X as isGraphicForRelatableFeatureSupportedLayer,W as isRelatableFeatureSupportedLayer,K as isRelatableLayer,pe as isRelatedField,be as preLayerQueryCallback,Fe as preRequestCallback,fe as querySourceLayer,de as queryUpdatedFeature,A as shouldOpenInNewTab,k as substituteAttributes,G as substituteFieldsInLinksAndAttributes};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{deprecatedProperty as n}from"../../core/deprecate.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import o from"../../core/Logger.js";import{destroyMaybe as r}from"../../core/maybe.js";import{EsriPromiseMixin as a}from"../../core/Promise.js";import{watch as l}from"../../core/reactiveUtils.js";import{templateHasKey as u}from"../../core/string.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{flattenFieldInputs as g,flattenRelationshipInputs as y,parseFormTemplateString as _,isGroupInput as v,isGroupElement as C,isFieldElement as E,isRelationshipElement as I,isRelationshipInput as F,isFieldInput as x,getNormalizedFeatureTypeInfo as b}from"./featureFormUtils.js";import V from"./FieldInput.js";import{createFormExpressionArcadeExecutor as w}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as j}from"./FormExpressionsManager.js";import A from"./GroupInput.js";import T from"./RelationshipInput.js";const M=new t({attributes:{}}),R=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],L=["visibilityExpression"],N=["editableExpression","visibilityExpression"],S="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",k="#JSAPI_CONTINGENT_VALUE_ANY_HASH",P="#JSAPI_CONTINGENT_VALUE_NULL_HASH",H="esri.widgets.FeatureForm.FeatureFormViewModel",G=o.getLogger(H);let U=class extends(i(a(s.EventedAccessor))){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=M.clone(),this._initialFeature=M.clone(),this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.inputs=[],this.map=null,this.relatedRecordCallbacks=null,this.strict=!1}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate]),(([e,t])=>{null!=e&&(t?this._updateInputs():e.load().catch((()=>o.getLogger(this).error("Failed to load layer",e.loadError))))}),{equals:([e,t,n],[s,i,o])=>e===s&&t===i&&n===o,initial:!0}),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e)})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.handles.add([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=r(this._contingentValuesCache)}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i}=this;return{layer:f(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i}}get allFieldInputs(){return g(this.inputs)}get allRelationshipInputs(){return y(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():M.clone(),this._initialFeature=this._featureClone.clone(),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),this.contingencyConstraintViolations.clear(),null!=this._expressionsManager&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this.updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return null!=e&&e.description&&t?_(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return null!=e&&e.title&&t?_(e.title,this.getValues(),t.fieldsIndex):null}formHeaderVisible(){const{activeRelationshipInput:e,formDescription:t,formTitle:n}=this;return!(e||!t&&!n)}set inputFields(e){n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs=e}get inputFields(){return n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>e.showAllEnabled=!1)),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get updating(){return this.updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}get view(){return n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._get("view")}set view(e){n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._set("view",e),e?.map&&(this.map=e.map)}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:n}=this,s=!!n?.getField(e);return t.getAttribute(e)??(s?null:void 0)}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),null!=this._expressionsManager&&this.updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:n}=this;n.geometry=t.geometry,null!=e&&this.updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}_updateInputs(){const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,map:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,map:r},l=i.slice(),u=null!=s&&s.elements&&s.elements.length>0?this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u}_updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(v(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(O),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});this.updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=g(o);return this._createExpressionsManager(e,t),this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[r,a]of s.entries())s.delete(r),a.destroy();return o}_updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):C(a)?this._makeGroupInputFromElement(a,s):E(a)?this._makeFieldInputFromElement(a,s,i):I(a)?this._makeRelationshipInputFromElement(a,s,i):null;if(n){if(r.push(n),e)if(t.delete(a),v(n)){const{feature:e}=s;n.set({feature:e})}else if(F(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({element:a,showAllEnabled:e})}else n.set(s);else this._assignExpressionExecutors(n,a,o);if(C(a)){const e=a.elements.filter((e=>O(e)));n.inputs=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return o.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(v(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else F(o)?o.destroy():x(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[],{arcadeEditType:r,feature:a,initialFeature:l,layer:u}=n;for(const o of t){const e=s.get(o)??new V({arcadeEditType:r,field:o,feature:a,initialFeature:l,layer:u,value:a?.getAttribute(o.name)??null});i.push(e),s.delete(o)}for(const[o,p]of s.entries())s.delete(o),p.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r}=t,{fieldName:a}=e,l=a&&this._layerFieldsByName.get(a);return l?new V({arcadeEditType:s,element:e,field:l,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n}):null}_makeGroupInputFromElement(e,t){const{feature:n,layer:s}=t;return new A({element:e,inputs:[],feature:n,layer:s})}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o}=t;return new T({element:e,feature:i,group:n,layer:o,map:s})}_assignExpressionExecutors(e,t,n){const s=C(t)?L:I(t)?N:R,i=[];for(const o of s){const s=t[o],{_expressionExecutorLookup:i}=this;if(null!=s&&""!==s){const t=`${o}Executor`,r=this._expressionLookup.get(s)??this._addToExpressionLookup(s);if(i.has(r))e[t]=i.get(r);else if(n.has(r)){const s=n.get(r).then((n=>(e[t]=n,n)));n.set(r,s)}else{const s=w(r,this.layer).then((n=>(e[t]=n,i.set(r,n),n)));n.set(r,s)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:n,_featureClone:s}=this;this._expressionsManager=new j({executors:e,feature:s,arcadeContextInfo:n,fieldInputs:t})}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=b(o);if(t===a&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);s.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(null!=i){const{description:e,title:n}=i;n&&u(n,t)&&this.notifyChange("formTitle"),e&&u(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:n}=this,s=null!=n&&null!=n.expressionInfos?Object.values(n.expressionInfos).find((t=>t.name===e)):null,i=s?.expression??e;return t.set(e,i),e!==i&&t.set(i,i),i}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=b(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(k)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(k),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(k)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(k),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:d,rightIsRange:f}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&d)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(n.minValue,o.minValue),g=Math.min(n.maxValue,o.maxValue);if(m>g)return null;s.values[i]=new h({objectType:"range",minValue:m,maxValue:g})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===k)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,r=new Set,a=new Set;for(const l of i)if(o.has(l)){const e=this.layer?.getFieldDomain(l,{feature:this.feature});if(null==e)continue;switch(e.type){case"coded-value":r.add(l);break;case"range":a.add(l)}}return{codedValueFields:[...r],rangeFields:[...a]}}_hashContingency(e,t,n=!1){if(t.length<1)return[S,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[k,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${P}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};function O(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||(o.getLogger(H).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}e([p()],U.prototype,"_featureClone",void 0),e([p()],U.prototype,"activeRelationshipInput",null),e([p()],U.prototype,"_arcadeContextInfo",null),e([p({readOnly:!0})],U.prototype,"allFieldInputs",null),e([p()],U.prototype,"allRelationshipInputs",null),e([p()],U.prototype,"_layerFieldsByName",null),e([p()],U.prototype,"arcadeEditType",void 0),e([p()],U.prototype,"contingencyConstraintViolations",void 0),e([p()],U.prototype,"disabled",void 0),e([p()],U.prototype,"feature",null),e([p()],U.prototype,"fieldsWithContingentValues",null),e([p({type:d})],U.prototype,"formTemplate",null),e([p()],U.prototype,"formDescription",null),e([p()],U.prototype,"formTitle",null),e([p()],U.prototype,"formHeaderVisible",null),e([p()],U.prototype,"inputs",void 0),e([p()],U.prototype,"inputFields",null),e([p()],U.prototype,"joinedContingentValues",null),e([p()],U.prototype,"layer",null),e([p()],U.prototype,"map",void 0),e([p()],U.prototype,"relatedRecordCallbacks",void 0),e([p()],U.prototype,"relationshipId",null),e([p()],U.prototype,"spatialReference",null),e([p()],U.prototype,"state",null),e([p()],U.prototype,"strict",void 0),e([p()],U.prototype,"submittable",null),e([p()],U.prototype,"updating",null),e([p()],U.prototype,"valid",null),e([p()],U.prototype,"view",null),e([p()],U.prototype,"getValues",null),e([p()],U.prototype,"submit",null),U=e([c(H)],U);const $=U;export{$ as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{deprecatedProperty as n}from"../../core/deprecate.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import o from"../../core/Logger.js";import{destroyMaybe as r}from"../../core/maybe.js";import{EsriPromiseMixin as a}from"../../core/Promise.js";import{watch as l}from"../../core/reactiveUtils.js";import{templateHasKey as u}from"../../core/string.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{flattenFieldInputs as g,flattenRelationshipInputs as y,parseFormTemplateString as _,isGroupInput as v,isGroupElement as C,isFieldElement as E,isRelationshipElement as I,isRelationshipInput as F,isFieldInput as x,getNormalizedFeatureTypeInfo as b}from"./featureFormUtils.js";import V from"./FieldInput.js";import{createFormExpressionArcadeExecutor as w}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as j}from"./FormExpressionsManager.js";import A from"./GroupInput.js";import T from"./RelationshipInput.js";const M=new t({attributes:{}}),R=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],L=["visibilityExpression"],N=["editableExpression","visibilityExpression"],S="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",k="#JSAPI_CONTINGENT_VALUE_ANY_HASH",P="#JSAPI_CONTINGENT_VALUE_NULL_HASH",H="esri.widgets.FeatureForm.FeatureFormViewModel",G=o.getLogger(H);let U=class extends(i(a(s.EventedAccessor))){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=M.clone(),this._initialFeature=M.clone(),this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.inputs=[],this.map=null,this.relatedRecordCallbacks=null,this.strict=!1}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate]),(([e,t])=>{null!=e&&(t?this._updateInputs():e.load().catch((()=>o.getLogger(this).error("Failed to load layer",e.loadError))))}),{equals:([e,t,n],[s,i,o])=>e===s&&t===i&&n===o,initial:!0}),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e)})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.handles.add([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=r(this._contingentValuesCache)}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i}=this;return{layer:f(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i}}get allFieldInputs(){return g(this.inputs)}get allRelationshipInputs(){return y(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():M.clone(),this._initialFeature=this._featureClone.clone(),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),this.contingencyConstraintViolations.clear(),null!=this._expressionsManager&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this.updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return null!=e&&e.description&&t?_(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return null!=e&&e.title&&t?_(e.title,this.getValues(),t.fieldsIndex):null}formHeaderVisible(){const{activeRelationshipInput:e,formDescription:t,formTitle:n}=this;return!(e||!t&&!n)}set inputFields(e){n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs=e}get inputFields(){return n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>e.showAllEnabled=!1)),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get updating(){return this.updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}get view(){return n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._get("view")}set view(e){n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._set("view",e),e?.map&&(this.map=e.map)}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:n}=this,s=!!n?.getField(e);return t.getAttribute(e)??(s?null:void 0)}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),null!=this._expressionsManager&&this.updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:n}=this;n.geometry=t.geometry,null!=e&&this.updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}_updateInputs(){const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,map:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,map:r},l=i.slice(),u=null!=s&&s.elements&&s.elements.length>0?this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u}_updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(v(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(O),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});this.updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=g(o);return this._createExpressionsManager(e,t),this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[r,a]of s.entries())s.delete(r),a.destroy();return o}_updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):C(a)?this._makeGroupInputFromElement(a,s):E(a)?this._makeFieldInputFromElement(a,s,i):I(a)?this._makeRelationshipInputFromElement(a,s,i):null;if(n){if(r.push(n),e)if(t.delete(a),v(n)){const{feature:e}=s;n.set({feature:e})}else if(F(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({showAllEnabled:e})}else n.set(s);else this._assignExpressionExecutors(n,a,o);if(C(a)){const e=a.elements.filter((e=>O(e)));n.inputs=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return o.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(v(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else F(o)?o.destroy():x(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[],{arcadeEditType:r,feature:a,initialFeature:l,layer:u}=n;for(const o of t){const e=s.get(o)??new V({arcadeEditType:r,field:o,feature:a,initialFeature:l,layer:u,value:a?.getAttribute(o.name)??null});i.push(e),s.delete(o)}for(const[o,p]of s.entries())s.delete(o),p.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r}=t,{fieldName:a}=e,l=a&&this._layerFieldsByName.get(a);return l?new V({arcadeEditType:s,element:e,field:l,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n}):null}_makeGroupInputFromElement(e,t){const{feature:n,layer:s}=t;return new A({element:e,inputs:[],feature:n,layer:s})}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o}=t;return new T({element:e,feature:i,group:n,layer:o,map:s})}_assignExpressionExecutors(e,t,n){const s=C(t)?L:I(t)?N:R,i=[];for(const o of s){const s=t[o],{_expressionExecutorLookup:i}=this;if(null!=s&&""!==s){const t=`${o}Executor`,r=this._expressionLookup.get(s)??this._addToExpressionLookup(s);if(i.has(r))e[t]=i.get(r);else if(n.has(r)){const s=n.get(r).then((n=>(e[t]=n,n)));n.set(r,s)}else{const s=w(r,this.layer).then((n=>(e[t]=n,i.set(r,n),n)));n.set(r,s)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:n,_featureClone:s}=this;this._expressionsManager=new j({executors:e,feature:s,arcadeContextInfo:n,fieldInputs:t})}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=b(o);if(t===a&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);s.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(null!=i){const{description:e,title:n}=i;n&&u(n,t)&&this.notifyChange("formTitle"),e&&u(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:n}=this,s=null!=n&&null!=n.expressionInfos?Object.values(n.expressionInfos).find((t=>t.name===e)):null,i=s?.expression??e;return t.set(e,i),e!==i&&t.set(i,i),i}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=b(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(k)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(k),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(k)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(k),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:d,rightIsRange:f}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&d)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(n.minValue,o.minValue),g=Math.min(n.maxValue,o.maxValue);if(m>g)return null;s.values[i]=new h({objectType:"range",minValue:m,maxValue:g})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===k)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,r=new Set,a=new Set;for(const l of i)if(o.has(l)){const e=this.layer?.getFieldDomain(l,{feature:this.feature});if(null==e)continue;switch(e.type){case"coded-value":r.add(l);break;case"range":a.add(l)}}return{codedValueFields:[...r],rangeFields:[...a]}}_hashContingency(e,t,n=!1){if(t.length<1)return[S,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[k,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${P}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};function O(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||(o.getLogger(H).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}e([p()],U.prototype,"_featureClone",void 0),e([p()],U.prototype,"activeRelationshipInput",null),e([p()],U.prototype,"_arcadeContextInfo",null),e([p({readOnly:!0})],U.prototype,"allFieldInputs",null),e([p()],U.prototype,"allRelationshipInputs",null),e([p()],U.prototype,"_layerFieldsByName",null),e([p()],U.prototype,"arcadeEditType",void 0),e([p()],U.prototype,"contingencyConstraintViolations",void 0),e([p()],U.prototype,"disabled",void 0),e([p()],U.prototype,"feature",null),e([p()],U.prototype,"fieldsWithContingentValues",null),e([p({type:d})],U.prototype,"formTemplate",null),e([p()],U.prototype,"formDescription",null),e([p()],U.prototype,"formTitle",null),e([p()],U.prototype,"formHeaderVisible",null),e([p()],U.prototype,"inputs",void 0),e([p()],U.prototype,"inputFields",null),e([p()],U.prototype,"joinedContingentValues",null),e([p()],U.prototype,"layer",null),e([p()],U.prototype,"map",void 0),e([p()],U.prototype,"relatedRecordCallbacks",void 0),e([p()],U.prototype,"relationshipId",null),e([p()],U.prototype,"spatialReference",null),e([p()],U.prototype,"state",null),e([p()],U.prototype,"strict",void 0),e([p()],U.prototype,"submittable",null),e([p()],U.prototype,"updating",null),e([p()],U.prototype,"valid",null),e([p()],U.prototype,"view",null),e([p()],U.prototype,"getValues",null),e([p()],U.prototype,"submit",null),U=e([c(H)],U);const $=U;export{$ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as r}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import i from"../Feature/FeatureRelationship/FeatureRelationshipViewModel.js";import{isRelatableFeatureSupportedLayer as l}from"../Feature/support/featureUtils.js";import a from"./EditableInput.js";const n=3;let p=class extends a{constructor(e){super(e),this._relationshipVM=null,this.group=null,this.type="relationship",this.handles.add([t((()=>({feature:this.feature,element:this.element,layer:this.layer})),(e=>this._createRelationshipVM(e)),r)])}destroy(){this._relationshipVM?.destroy()}get canAddRelatedFeature(){const{editable:e,featureCount:t,_relationshipVM:r}=this;if(!r?.relationship)return!1;const{cardinality:s,role:o}=r.relationship;return!("one-to-one"===s&&t>0)&&("many-to-many"!==s&&(!("one-to-many"===s&&"destination"===o&&t>0)&&e))}get displayCount(){return this.element.displayCount??n}get displayType(){return this.element.displayType}get editable(){return!!this.layerAllowsEdits&&(this.evaluatedEditableExpression??!0)}get featureCount(){return this._relationshipVM?.featureCount??0}get map(){return this._get("map")}set map(e){e&&this._relationshipVM?.set("map",e),this._set("map",e)}get orderByFields(){return this.element.orderByFields}get relationshipId(){return this.element.relationshipId}get relatedFeatureInfos(){return this._relationshipVM?.relatedFeatureInfos??[]}get relatedLayer(){return this._relationshipVM?.relatedLayer}get showAllEnabled(){return this._get("showAllEnabled")}set showAllEnabled(e){this._relationshipVM?.set("showAllEnabled",e),this._set("showAllEnabled",e)}get showAllActionVisible(){return!this.showAllEnabled&&this.featureCount>0&&this.featureCount>this.displayCount}get updating(){return"loading"===this._relationshipVM?.state||"querying"===this._relationshipVM?.state}incrementPage(){this._relationshipVM&&this._relationshipVM.featurePage++}getRelatedFeatureByObjectId(e){return this._relationshipVM?.getRelatedFeatureByObjectId(e)}_createRelationshipVM(e){const{feature:t,element:r,layer:s}=e;if(this._relationshipVM?.destroy(),!t||!r||!s)return;const{displayCount:o,map:a,orderByFields:n,relationshipId:p,showAllEnabled:u}=this;l(s)&&(this._relationshipVM=new i({graphic:t,displayCount:o,layer:s,map:a,orderByFields:n,relationshipId:p,showAllEnabled:u}))}};e([s()],p.prototype,"canAddRelatedFeature",null),e([s()],p.prototype,"displayCount",null),e([s()],p.prototype,"displayType",null),e([s()],p.prototype,"editable",null),e([s()],p.prototype,"group",void 0),e([s()],p.prototype,"map",null),e([s()],p.prototype,"orderByFields",null),e([s()],p.prototype,"relationshipId",null),e([s()],p.prototype,"relatedFeatureInfos",null),e([s()],p.prototype,"relatedLayer",null),e([s()],p.prototype,"showAllEnabled",null),e([s()],p.prototype,"showAllActionVisible",null),e([s({readOnly:!0})],p.prototype,"type",void 0),e([s()],p.prototype,"updating",null),e([s()],p.prototype,"incrementPage",null),e([s()],p.prototype,"getRelatedFeatureByObjectId",null),p=e([o("esri.widgets.FeatureForm.RelationshipInput")],p);const u=p;export{u as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as r}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import i from"../Feature/FeatureRelationship/FeatureRelationshipViewModel.js";import{isRelatableFeatureSupportedLayer as l}from"../Feature/support/featureUtils.js";import a from"./EditableInput.js";const n=3;let p=class extends a{constructor(e){super(e),this._relationshipVM=null,this.group=null,this.type="relationship",this.handles.add([t((()=>({feature:this.feature,element:this.element,layer:this.layer})),(e=>this._createRelationshipVM(e)),r)])}destroy(){this._relationshipVM?.destroy()}get canAddRelatedFeature(){const{editable:e,featureCount:t,_relationshipVM:r}=this;if(!r?.relationship||!this.loaded)return!1;const{cardinality:s,role:o}=r.relationship;return!("one-to-one"===s&&t>0)&&("many-to-many"!==s&&(!("one-to-many"===s&&"destination"===o&&t>0)&&e))}get displayCount(){return this.element.displayCount??n}get displayType(){return this.element.displayType}get editable(){return!!this.layerAllowsEdits&&(this.evaluatedEditableExpression??!0)}get featureCount(){return this._relationshipVM?.featureCount??0}get map(){return this._get("map")}set map(e){e&&this._relationshipVM?.set("map",e),this._set("map",e)}get orderByFields(){return this.element.orderByFields}get relationshipId(){return this.element.relationshipId}get relatedFeatureInfos(){return this._relationshipVM?.relatedFeatureInfos??[]}get relatedLayer(){return this._relationshipVM?.relatedLayer}get showAllEnabled(){return this._get("showAllEnabled")}set showAllEnabled(e){this._relationshipVM?.set("showAllEnabled",e),this._set("showAllEnabled",e)}get showAllActionVisible(){return!this.showAllEnabled&&this.featureCount>0&&this.featureCount>this.displayCount}get updating(){return"loading"===this._relationshipVM?.state||"querying"===this._relationshipVM?.state}get loaded(){return"ready"===this._relationshipVM?.state}incrementPage(){this._relationshipVM&&this._relationshipVM.featurePage++}getRelatedFeatureByObjectId(e){return this._relationshipVM?.getRelatedFeatureByObjectId(e)}_createRelationshipVM(e){const{feature:t,element:r,layer:s}=e;if(this._relationshipVM?.destroy(),!t||!r||!s)return;const{displayCount:o,map:a,orderByFields:n,relationshipId:p,showAllEnabled:u}=this;l(s)&&(this._relationshipVM=new i({graphic:t,displayCount:o,layer:s,map:a,orderByFields:n,relationshipId:p,showAllEnabled:u}))}};e([s()],p.prototype,"canAddRelatedFeature",null),e([s()],p.prototype,"displayCount",null),e([s()],p.prototype,"displayType",null),e([s()],p.prototype,"editable",null),e([s()],p.prototype,"group",void 0),e([s()],p.prototype,"map",null),e([s()],p.prototype,"orderByFields",null),e([s()],p.prototype,"relationshipId",null),e([s()],p.prototype,"relatedFeatureInfos",null),e([s()],p.prototype,"relatedLayer",null),e([s()],p.prototype,"showAllEnabled",null),e([s()],p.prototype,"showAllActionVisible",null),e([s({readOnly:!0})],p.prototype,"type",void 0),e([s()],p.prototype,"updating",null),e([s()],p.prototype,"incrementPage",null),e([s()],p.prototype,"getRelatedFeatureByObjectId",null),p=e([o("esri.widgets.FeatureForm.RelationshipInput")],p);const u=p;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.27/esri/copyright.txt for details.
4
4
  */
5
- const e="esri-feature-form",i=`${e}__group`,t=`${e}__input`,r={base:e,form:`${e}__form`,formHeader:`${e}__form-header`,label:`${e}__label`,fieldInputWrapper:`${t}-wrapper`,fieldInputLoader:`${t}-loader`,fieldInput:`${t}`,inputDate:`${t}--date`,inputTime:`${t}--time`,inputRadioGroup:`${t}--radio-group`,inputRadio:`${t}--radio`,inputRadioLabel:`${t}--radio-label`,inputDisabled:`${t}--disabled`,inputSwitch:`${t}--switch`,inputInvalid:`${t}--invalid`,centeredButton:`${e}__centered-button`,description:`${e}__description-text`,listObserver:`${e}__list-observer`,relatedRecordList:`${e}__related-record-list`,dateInputContainer:`${`${e}__date`}-input-container`,group:i,groupLabel:`${i}-label`,groupHeader:`${i}-header`,groupTitle:`${i}-title`,groupToggleIcon:`${i}-toggle-icon`,groupCollapsed:`${i}--collapsed`,groupSequential:`${i}--sequential`,groupActive:`${i}--active`,collapseIcon:"esri-icon-up",expandIcon:"esri-icon-down",widget:"esri-widget",panel:"esri-widget--panel",input:"esri-input"};export{r as CSS};
5
+ const e="esri-feature-form",i=`${e}__group`,r=`${e}__input`,t=`${e}__related-records`,a={base:e,form:`${e}__form`,formHeader:`${e}__form-header`,label:`${e}__label`,relationshipLabel:`${e}__relationship-label`,fieldInputWrapper:`${r}-wrapper`,fieldInputLoader:`${r}-loader`,fieldInput:`${r}`,inputDate:`${r}--date`,inputTime:`${r}--time`,inputRadioGroup:`${r}--radio-group`,inputRadio:`${r}--radio`,inputRadioLabel:`${r}--radio-label`,inputDisabled:`${r}--disabled`,inputSwitch:`${r}--switch`,inputInvalid:`${r}--invalid`,centeredButton:`${e}__centered-button`,description:`${e}__description-text`,listObserver:`${e}__list-observer`,relatedRecordsHeader:`${t}_header`,relatedRecordsList:`${t}_list`,dateInputContainer:`${`${e}__date`}-input-container`,group:i,groupLabel:`${i}-label`,groupHeader:`${i}-header`,groupTitle:`${i}-title`,groupToggleIcon:`${i}-toggle-icon`,groupCollapsed:`${i}--collapsed`,groupSequential:`${i}--sequential`,groupActive:`${i}--active`,collapseIcon:"esri-icon-up",expandIcon:"esri-icon-down",widget:"esri-widget",panel:"esri-widget--panel",input:"esri-input"};export{a as CSS};