@arcgis/core 4.23.0-next.20220320 → 4.23.0

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 (39) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{678c94b331fde96e6998.js → 52c972e98d60a0c62a6b.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{e8e775758b79c5a084c8.js → 86ec93705546377103b0.js} +1 -1
  4. package/assets/esri/core/workers/chunks/9f458f10dc65b185f66e.js +1 -0
  5. package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +2 -2
  6. package/assets/esri/themes/base/widgets/_LayerList.scss +2 -2
  7. package/assets/esri/themes/dark/main.css +1 -1
  8. package/assets/esri/themes/dark-blue/main.css +1 -1
  9. package/assets/esri/themes/dark-green/main.css +1 -1
  10. package/assets/esri/themes/dark-purple/main.css +1 -1
  11. package/assets/esri/themes/dark-red/main.css +1 -1
  12. package/assets/esri/themes/light/main.css +1 -1
  13. package/assets/esri/themes/light/view.css +1 -1
  14. package/assets/esri/themes/light-blue/main.css +1 -1
  15. package/assets/esri/themes/light-green/main.css +1 -1
  16. package/assets/esri/themes/light-purple/main.css +1 -1
  17. package/assets/esri/themes/light-red/main.css +1 -1
  18. package/config.js +1 -1
  19. package/core/reactiveUtils.js +1 -1
  20. package/interfaces.d.ts +26 -4
  21. package/layers/support/FeatureReductionCluster.js +1 -1
  22. package/package.json +1 -1
  23. package/support/basemapUtils.js +1 -1
  24. package/support/revision.js +1 -1
  25. package/views/2d/engine/webgl/effects/HittestEffect.js +1 -1
  26. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  27. package/views/2d/layers/LayerView2D.js +1 -1
  28. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  29. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  30. package/views/layers/GroupLayerView.js +1 -1
  31. package/widgets/BasemapGallery/support/basemapCompatibilityUtils.js +1 -1
  32. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  33. package/widgets/Editor/EditorViewModel.js +1 -1
  34. package/widgets/Editor/deprecationUtils.js +5 -0
  35. package/widgets/Editor.js +1 -1
  36. package/widgets/Feature/FeatureMedia.js +1 -1
  37. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  38. package/widgets/FeatureForm/InputField.js +1 -1
  39. package/assets/esri/core/workers/chunks/70b0b6d9559960307059.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.23/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{isNone as a,isSome as t}from"../../../core/maybe.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{isTiledLayer as r,isWMTSLayer as n}from"../../../layers/support/layerUtils.js";import{stringFromViewingMode as o,ViewingMode as s}from"../../../views/ViewingMode.js";import{getTileInfoAndExtentFromWMTSLayer as l,isVectorTileLayer as p,checkIfTileInfoSupportedForView as c}from"../../../views/3d/terrain/terrainUtils.js";import m from"../../../views/3d/terrain/TilingScheme.js";import{isSpatialReferenceSupported as f}from"../../../views/support/spatialReferenceSupport.js";async function u(e,a={}){await b(e,a),i(a)}async function y(e,a={}){const{basemap:t,view:n}=e;if("spatialReferenceLocked"in n&&!n.spatialReferenceLocked)return;if(await t.load(a),i(a),0===t.baseLayers.length)return;const o=t.baseLayers.getItemAt(0);if(!r(o))return;if(t.spatialReference){if(n.spatialReference.equals(t.spatialReference))return;w()}await o.load(a),i(a);const s=(("supportedSpatialReferences"in o?o.supportedSpatialReferences:null)||["tileInfo"in o?o.tileInfo.spatialReference:null]).filter(Boolean);0!==s.length&&s.every((e=>!n.spatialReference.equals(e)))&&w()}function w(){throw new e("basemap-compatibility:incompatible-spatial-reference","Basemap spatial reference is not compatible with the view")}async function b(a,t){const{basemap:i,view:r}=a;if(await i.load(t),0===i.baseLayers.length)return;const n=h(i.baseLayers.concat(i.referenceLayers));if(n.length)throw n[0];const o=i.baseLayers.getItemAt(0);try{await o.load(t)}catch(s){const a="basemap-compatibility:unknown-error",t="Unknown basemap compatibility error",{name:i=a,message:r=t,details:n}=s;throw new e(i,r,n)}g(o,r)}function h(a){const t=["ArcGISTiledImageServiceLayer","ArcGISTiledMapServiceLayer","OpenStreetMap","VectorTileLayer","WebTiledLayer"];return a.toArray().filter((e=>-1===t.indexOf(e.operationalLayerType))).map((a=>new e("basemap-compatibility:unsupported-basemap-layer-type","Unsupported basemap layer type ${operationalLayerType}",{layer:a,operationalLayerType:a.operationalLayerType||"unknown"})))}function g(i,r){const u=r.state.viewingMode;if(!u)return;let y=i.tileInfo,w=i.fullExtent;if(n(i)){const t=l(i,r.spatialReference,u);if(a(t.tileInfo))throw new e("basemapgalleryitem:tiling-scheme-incompatible","Basemap tiling scheme is incompatible with the view");y=t.tileInfo,w=t.fullExtent}if(a(y))return;if(!f(y.spatialReference,u))throw new e(`basemapgalleryitem:spatial-reference-unsupported-${o(u)}`,`Basemap spatial reference is unsupported in ${o(u)} mode`);const b=y.spatialReference.isGeographic,h=p(i)?y.getOrCreateCompatible(256,b?1:2):null;if(u===s.Global){let a=c(y,w,null,u);if(a&&p(i)&&t(w)&&h&&!c(h,w,null,u)&&(a=null),a){const t=y.spatialReference.isWebMercator?"web-mercator":"wgs84";throw new e(`basemapgalleryitem:tiling-scheme-unsupported-${t}-global`,"Basemap tiling scheme is unsupported in global mode",{error:a})}}else if(m.checkUnsupported(y))throw new e("basemapgalleryitem:tiling-scheme-unsupported-local","Basemap tiling scheme is unsupported in local mode");const g=r.get("basemapTerrain.tilingScheme");if(g&&!g.compatibleWith(y)&&!(p(i)&&h&&g.compatibleWith(h)))throw new e("basemapgalleryitem:tiling-scheme-incompatible","Basemap tiling scheme is incompatible with the view")}export{y as default2DCompatibility,u as default3DCompatibility};
5
+ import e from"../../../core/Error.js";import{isNone as a,isSome as t}from"../../../core/maybe.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{isTiledLayer as r,isWMTSLayer as n}from"../../../layers/support/layerUtils.js";import{stringFromViewingMode as o,ViewingMode as s}from"../../../views/ViewingMode.js";import{getTileInfoAndExtentFromWMTSLayer as l,isVectorTileLayer as p,checkIfTileInfoSupportedForView as c}from"../../../views/3d/terrain/terrainUtils.js";import m from"../../../views/3d/terrain/TilingScheme.js";import{isSpatialReferenceSupported as f}from"../../../views/support/spatialReferenceSupport.js";async function u(e,a={}){await b(e,a),i(a)}async function y(e,a={}){const{basemap:t,view:n}=e;if(i(a),"spatialReferenceLocked"in n&&!n.spatialReferenceLocked)return;if(await t.load(a),i(a),0===t.baseLayers.length)return;const o=t.baseLayers.getItemAt(0);if(!r(o))return;if(t.spatialReference){if(n.spatialReference.equals(t.spatialReference))return;w()}await o.load(a),i(a);const s=(("supportedSpatialReferences"in o?o.supportedSpatialReferences:null)||["tileInfo"in o?o.tileInfo.spatialReference:null]).filter(Boolean);0!==s.length&&s.every((e=>!n.spatialReference.equals(e)))&&w()}function w(){throw new e("basemap-compatibility:incompatible-spatial-reference","Basemap spatial reference is not compatible with the view")}async function b(a,t){const{basemap:i,view:r}=a;if(await i.load(t),0===i.baseLayers.length)return;const n=h(i.baseLayers.concat(i.referenceLayers));if(n.length)throw n[0];const o=i.baseLayers.getItemAt(0);try{await o.load(t)}catch(s){const a="basemap-compatibility:unknown-error",t="Unknown basemap compatibility error",{name:i=a,message:r=t,details:n}=s;throw new e(i,r,n)}g(o,r)}function h(a){const t=["ArcGISTiledImageServiceLayer","ArcGISTiledMapServiceLayer","OpenStreetMap","VectorTileLayer","WebTiledLayer"];return a.toArray().filter((e=>-1===t.indexOf(e.operationalLayerType))).map((a=>new e("basemap-compatibility:unsupported-basemap-layer-type","Unsupported basemap layer type ${operationalLayerType}",{layer:a,operationalLayerType:a.operationalLayerType||"unknown"})))}function g(i,r){const u=r.state.viewingMode;if(!u)return;let y=i.tileInfo,w=i.fullExtent;if(n(i)){const t=l(i,r.spatialReference,u);if(a(t.tileInfo))throw new e("basemapgalleryitem:tiling-scheme-incompatible","Basemap tiling scheme is incompatible with the view");y=t.tileInfo,w=t.fullExtent}if(a(y))return;if(!f(y.spatialReference,u))throw new e(`basemapgalleryitem:spatial-reference-unsupported-${o(u)}`,`Basemap spatial reference is unsupported in ${o(u)} mode`);const b=y.spatialReference.isGeographic,h=p(i)?y.getOrCreateCompatible(256,b?1:2):null;if(u===s.Global){let a=c(y,w,null,u);if(a&&p(i)&&t(w)&&h&&!c(h,w,null,u)&&(a=null),a){const t=y.spatialReference.isWebMercator?"web-mercator":"wgs84";throw new e(`basemapgalleryitem:tiling-scheme-unsupported-${t}-global`,"Basemap tiling scheme is unsupported in global mode",{error:a})}}else if(m.checkUnsupported(y))throw new e("basemapgalleryitem:tiling-scheme-unsupported-local","Basemap tiling scheme is unsupported in local mode");const g=r.get("basemapTerrain.tilingScheme");if(g&&!g.compatibleWith(y)&&!(p(i)&&h&&g.compatibleWith(h)))throw new e("basemapgalleryitem:tiling-scheme-incompatible","Basemap tiling scheme is incompatible with the view")}export{y as default2DCompatibility,u as default3DCompatibility};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{remove as t}from"../../core/arrayUtils.js";import{makeHandle as a}from"../../core/handleUtils.js";import{removeMaybe as r,isSome as i,isNone as s,destroyMaybe as o}from"../../core/maybe.js";import{watch as n,syncAndInitial as l}from"../../core/reactiveUtils.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import"../../core/accessorSupport/set.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import u from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as d}from"./CreateFeaturesWorkflowData.js";import h from"./Workflow.js";import{startCreatingNewFeature as p,findLayerInfo as f,updateGraphicSymbolWhenRequired as m,getVisualVariableAttributes as g,startUpdatingFeature as v,createWorkflowSteps as w,avoidFeatureTemplateSelectionWithOnlyOneItem as y,visualVariableInteractiveUpdate as M}from"./workflowUtils.js";var b;let V=b=class extends h{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.featureFormHandle=null,this.visualVariableAttributes={rotation:null,size:null},this.highlightHandles=new Map,this.preventDefaultActionOnCancel=!1}get numPendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics.length}get pendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics}async updatePendingFeature(e){return this.preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),t(this.lastActiveGraphics,e),this._startUpdating(e)}static create(e,t,a,r){const i=new b({data:new d({creationInfo:t,viewModel:e}),onCommit:async e=>{await r(e.creationInfo.layer,{addFeatures:e.viewModel.sketchViewModel.layer.graphics.toArray()})}});return i._set("steps",this._createWorkflowSteps(i,a)),i}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",a((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,a((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t.type&&this.highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){r(this.highlightHandles.get(e)),this.highlightHandles.delete(e)}async _startCreating(){return this.createFeatureState="create-new",p(this.data.viewModel.sketchViewModel,this.data.creationInfo)}async _startUpdating(e){const t=this.data.viewModel,a=t.sketchViewModel,i=this.data.creationInfo.layer,s=f(t.layerInfos,i),o=null==s?void 0:s.formTemplate;return t.featureFormViewModel.set({feature:e,formTemplate:o}),r(this.featureFormHandle),this.featureFormHandle=t.featureFormViewModel.on("value-change",(async()=>{e.attributes=t.featureFormViewModel.getValues(),await m(e)})),this._removeHighlight(e),this.createFeatureState="update-pending",this.visualVariableAttributes=g(e),v(a,e,i,this.visualVariableAttributes)}static _createWorkflowSteps(e,a="awaiting-feature-creation-info"){const{data:c,handles:d}=e;let h=null,p=!0;const f=w(["awaiting-feature-creation-info","creating-features"],a,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){c.creationInfo=null,d.add(c.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{c.creationInfo={layer:e.layer,template:e.template},c.viewModel.activeWorkflow.next()})),this.id)},async tearDown(){d.remove(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){const a=c.viewModel.view,f=c.viewModel.sketchViewModel;p=f.updateOnGraphicClick,f.updateOnGraphicClick=!1,e.lastActiveGraphics=[],e.featureFormHandle=r(e.featureFormHandle),e.visualVariableAttributes={rotation:null,size:null};const m="2d"===a.type?e._fadeExistingFeatures(c.creationInfo.layer):null,g=f.on("create",(async t=>{if("cancel"===t.state){if(e.preventDefaultActionOnCancel)return void(e.preventDefaultActionOnCancel=!1);if(e.lastActiveGraphics.length<1)return e._startCreating();const t=e.lastActiveGraphics.pop();return e._startUpdating(t)}if("complete"===t.state)return e._startUpdating(t.graphic)})),v=f.on("update",(async t=>{const r=t.graphics[0];if("complete"===t.state)return r!==h&&(e.lastActiveGraphics.push(r),e._highlight(r)),h=null,t.aborted&&e.preventDefaultActionOnCancel?void(e.preventDefaultActionOnCancel=!1):e._startCreating();"start"===t.state&&e._removeHighlight(r),await M(a,r,t,e.visualVariableAttributes);const s=r.attributes;if(i(e.visualVariableAttributes.rotation)){const{field:t}=e.visualVariableAttributes.rotation;c.viewModel.featureFormViewModel.setValue(t,s[t])}if(i(e.visualVariableAttributes.size)){const{field:t}=e.visualVariableAttributes.size;c.viewModel.featureFormViewModel.setValue(t,s[t])}})),w=f.on("delete",(async a=>{const r=a.graphics[0];t(e.lastActiveGraphics,r),h=r}));let y=null;const b=n((()=>{var e;const t=f.snappingOptions.featureSources.find((e=>e.layer===c.creationInfo.layer));return{hasFeatureLayerSource:!!t,enabled:null!=(e=null==t?void 0:t.enabled)&&e}}),(({hasFeatureLayerSource:e,enabled:t})=>{const a=f.snappingOptions.featureSources;e?(s(y)&&(y=new u({layer:f.layer,enabled:t}),a.add(y)),y.enabled=t):(i(y)&&a.remove(y),y=o(y))}),l),V=a.on("immediate-click",(async t=>{const r=await a.hitTest(t,{include:f.layer});if(r.results.length>0){const t=r.results[0].graphic;if("transform"===f.activeTool||"reshape"===f.activeTool){if(f.updateGraphics.getItemAt(0)===t)return;await e.updatePendingFeature(t)}}}));await e._startCreating();const F={remove:()=>{r(e.featureFormHandle),g.remove(),v.remove(),w.remove(),b.remove(),i(y)&&f.snappingOptions.featureSources.remove(y),y=o(y),f.cancel(),V.remove(),r(m)}};d.add(F,this.id)},async tearDown(e){e.cancelled&&c.viewModel.sketchViewModel.layer.removeAll(),d.remove(this.id),c.viewModel.sketchViewModel.updateOnGraphicClick=p}})});return y(c,f)}};V=b=e([c("esri.widgets.Editor.CreateFeaturesWorkflow")],V);const F=V;export{F as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{remove as t}from"../../core/arrayUtils.js";import{makeHandle as a}from"../../core/handleUtils.js";import{unwrap as r,removeMaybe as i,isSome as s,isNone as o,destroyMaybe as n}from"../../core/maybe.js";import{watch as l,syncAndInitial as c}from"../../core/reactiveUtils.js";import"../../core/Logger.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import"../../core/accessorSupport/set.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as h}from"./CreateFeaturesWorkflowData.js";import p from"./Workflow.js";import{startCreatingNewFeature as f,findLayerInfo as m,updateGraphicSymbolWhenRequired as g,getVisualVariableAttributes as v,startUpdatingFeature as w,createWorkflowSteps as y,avoidFeatureTemplateSelectionWithOnlyOneItem as M,visualVariableInteractiveUpdate as b}from"./workflowUtils.js";var V;let F=V=class extends p{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.featureFormHandle=null,this.visualVariableAttributes={rotation:null,size:null},this.highlightHandles=new Map,this.preventDefaultActionOnCancel=!1}get numPendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics.length}get pendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics}async updatePendingFeature(e){return this.preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),t(this.lastActiveGraphics,e),this._startUpdating(e)}static create(e,t,a,i){const s=new V({data:new h({creationInfo:r(t),viewModel:e}),onCommit:async e=>{await i(e.creationInfo.layer,{addFeatures:e.viewModel.sketchViewModel.layer.graphics.toArray()})}});return s._set("steps",this._createWorkflowSteps(s,a)),s}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",a((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,a((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t.type&&this.highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){i(this.highlightHandles.get(e)),this.highlightHandles.delete(e)}async _startCreating(){return this.createFeatureState="create-new",f(this.data.viewModel.sketchViewModel,this.data.creationInfo)}async _startUpdating(e){const t=this.data.viewModel,a=t.sketchViewModel,r=this.data.creationInfo.layer,s=m(t.layerInfos,r),o=null==s?void 0:s.formTemplate;return t.featureFormViewModel.set({feature:e,formTemplate:o}),i(this.featureFormHandle),this.featureFormHandle=t.featureFormViewModel.on("value-change",(async()=>{e.attributes=t.featureFormViewModel.getValues(),await g(e)})),this._removeHighlight(e),this.createFeatureState="update-pending",this.visualVariableAttributes=v(e),w(a,e,r,this.visualVariableAttributes)}static _createWorkflowSteps(e,a="awaiting-feature-creation-info"){const{data:r,handles:u}=e;let h=null,p=!0;const f=y(["awaiting-feature-creation-info","creating-features"],a,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){r.creationInfo=null,u.add(r.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{r.creationInfo={layer:e.layer,template:e.template},r.viewModel.activeWorkflow.next()})),this.id)},async tearDown(){u.remove(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){const a=r.viewModel.view,f=r.viewModel.sketchViewModel;p=f.updateOnGraphicClick,f.updateOnGraphicClick=!1,e.lastActiveGraphics=[],e.featureFormHandle=i(e.featureFormHandle),e.visualVariableAttributes={rotation:null,size:null};const m="2d"===a.type?e._fadeExistingFeatures(r.creationInfo.layer):null,g=f.on("create",(async t=>{if("cancel"===t.state){if(e.preventDefaultActionOnCancel)return void(e.preventDefaultActionOnCancel=!1);if(e.lastActiveGraphics.length<1)return e._startCreating();const t=e.lastActiveGraphics.pop();return e._startUpdating(t)}if("complete"===t.state)return e._startUpdating(t.graphic)})),v=f.on("update",(async t=>{const i=t.graphics[0];if("complete"===t.state)return i!==h&&(e.lastActiveGraphics.push(i),e._highlight(i)),h=null,t.aborted&&e.preventDefaultActionOnCancel?void(e.preventDefaultActionOnCancel=!1):e._startCreating();"start"===t.state&&e._removeHighlight(i),await b(a,i,t,e.visualVariableAttributes);const o=i.attributes;if(s(e.visualVariableAttributes.rotation)){const{field:t}=e.visualVariableAttributes.rotation;r.viewModel.featureFormViewModel.setValue(t,o[t])}if(s(e.visualVariableAttributes.size)){const{field:t}=e.visualVariableAttributes.size;r.viewModel.featureFormViewModel.setValue(t,o[t])}})),w=f.on("delete",(async a=>{const r=a.graphics[0];t(e.lastActiveGraphics,r),h=r}));let y=null;const M=l((()=>{var e;const t=f.snappingOptions.featureSources.find((e=>e.layer===r.creationInfo.layer));return{hasFeatureLayerSource:!!t,enabled:null!=(e=null==t?void 0:t.enabled)&&e}}),(({hasFeatureLayerSource:e,enabled:t})=>{const a=f.snappingOptions.featureSources;e?(o(y)&&(y=new d({layer:f.layer,enabled:t}),a.add(y)),y.enabled=t):(s(y)&&a.remove(y),y=n(y))}),c),V=a.on("immediate-click",(async t=>{const r=await a.hitTest(t,{include:f.layer});if(r.results.length>0){const t=r.results[0].graphic;if("transform"===f.activeTool||"reshape"===f.activeTool){if(f.updateGraphics.getItemAt(0)===t)return;await e.updatePendingFeature(t)}}}));await e._startCreating();const F={remove:()=>{i(e.featureFormHandle),g.remove(),v.remove(),w.remove(),M.remove(),s(y)&&f.snappingOptions.featureSources.remove(y),y=n(y),f.cancel(),V.remove(),i(m)}};u.add(F,this.id)},async tearDown(e){e.cancelled&&r.viewModel.sketchViewModel.layer.removeAll(),u.remove(this.id),r.viewModel.sketchViewModel.updateOnGraphicClick=p}})});return M(r,f)}};F=V=e([u("esri.widgets.Editor.CreateFeaturesWorkflow")],F);const A=F;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.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import r from"../../core/Error.js";import a from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import i from"../../core/Logger.js";import{on as s,init as n,watch as l,whenFalseOnce as d}from"../../core/watchUtils.js";import{aliasOf as c}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import u from"../../layers/GraphicsLayer.js";import f from"../../views/interactive/snapping/SnappingOptions.js";import h from"../Attachments/AttachmentsViewModel.js";import m from"./CreateFeaturesWorkflow.js";import k from"./CreateWorkflow.js";import y from"./UpdateWorkflow.js";import v from"../FeatureForm/FeatureFormViewModel.js";import W from"../FeatureTemplates/FeatureTemplatesViewModel.js";import g from"../Sketch/SketchViewModel.js";import _ from"../Spinner/SpinnerViewModel.js";const C="esri.widgets.Editor.EditorViewModel",b=i.getLogger(C),F=["create","create-features","update"];function j(e,t,a){b.error(new r(e,t,a))}function M(e,t){return e&&e.find((e=>e.layer===t))}let V=class extends(o(a.EventedAccessor)){constructor(e){super(e),this._sketchGraphicsLayer=new u({listMode:"hide",internal:!0}),this.activeWorkflow=null,this.activityQueue=[],this.failures=[],this.attachmentsViewModel=new h({abilities:{editing:!0}}),this.featureFormViewModel=new v,this.featureTemplatesViewModel=new W,this.layerInfos=null,this.sketchViewModel=new g({layer:this._sketchGraphicsLayer}),this.snappingOptions=new f,this.spinnerViewModel=new _}initialize(){this.handles.add([s(this,"activeWorkflow","cancel",(()=>this.emit("workflow-cancel"))),s(this,"activeWorkflow","commit",(()=>this.emit("workflow-commit"))),n(this,"view.map",(e=>{e&&e.add(this._sketchGraphicsLayer)})),l(this,"editableItems",(()=>{const{activeWorkflow:e}=this;if(this.refreshCreationTemplates(),!e)return;const{stepId:t}=e;"create"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdate||"awaiting-update-feature-candidate"===t&&!e.data.candidates.some((e=>{const t=this.editableItems.find((t=>t.layer===e.layer));return t&&t.supports.indexOf("update")>-1})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}))])}destroy(){this._cancelWorkflow().then((()=>{var e;null!=(e=this.view)&&e.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null}))}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(e){e&&0!==e.length||(e=[...F]),this._set("allowedWorkflows",e)}get canCreate(){return this.editableItems.some((e=>e.supports.includes("create")))}get canUpdate(){return this.editableItems.some((e=>e.supports.includes("update")))}get editableItems(){var e,r,a;const o=null==(e=this.view)?void 0:e.allLayerViews;if(!o)return new t;const i=new Set(null==(r=this.view)||null==(a=r.map)?void 0:a.editableLayers);return o.filter((e=>i.has(e.layer))).map((e=>{const{layer:t,suspended:r}=e,{data:a,operations:o}=t.capabilities,i=M(this.layerInfos,t),s="supportsAttachment"in a&&a.supportsAttachment&&(!i||!1!==i.allowAttachments);if(r)return{hasAttachments:s,layer:t,supports:[]};const n=[];return o.supportsAdd&&(this.allowedWorkflows.includes("create")||this.allowedWorkflows.includes("create-features"))&&(!i||!1!==i.enabled&&!1!==i.addEnabled)&&n.push("create"),o.supportsUpdate&&this.allowedWorkflows.includes("update")&&(!i||!1!==i.enabled&&!1!==i.updateEnabled)&&n.push("update"),!1!==(i&&i.deleteEnabled)&&o.supportsDelete&&n.push("delete"),{hasAttachments:s,layer:t,supports:n}})).reverse()}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this;return t?t.stepId:"ready"}get syncing(){return this.activityQueue.length>0}set view(e){this.sketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}async startCreateWorkflowAtFeatureTypeSelection(){if(!this.canCreate)return void j("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startCreateWorkflowAtFeatureCreation(e){if(!this.canCreate)return void j("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("awaiting-feature-to-create");t.data.creationInfo=e,await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(!this.canCreate)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(e,t);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(e){if(!this.canCreate)return void j("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("editing-new-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureSelection(){if(!this.canUpdate)return void j("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(!this.canUpdate)return void j("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureEdit(e){if(!this.canUpdate)return void j("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async deleteFeatureFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?(await this._delete(e.data.edits.feature),await e.reset()):j("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warn:!0,...e})}refreshCreationTemplates(){const e=[];for(const{layer:t,supports:r}of this.editableItems)t.loaded&&r.includes("create")&&e.push(t);this.featureTemplatesViewModel.layers=e}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e&&e.warn&&j("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await t.cancel(e);await t.cancel(e),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(e,t){return m.create(this,e,t,((e,t)=>this._applyEdits(e,t)))}_createCreateWorkflow(e){return k.create(this,e,((e,t)=>this._applyEdits(e,t)))}_createUpdateWorkflow(e){return y.create(this,e,((e,t)=>this._applyEdits(e,t)))}async _delete(e){const t=e.sourceLayer;"applyEdits"in t&&await this._applyEdits(t,{deleteFeatures:[e]})}async _applyEdits(e,t){await this._queueOperation((async()=>{const r=await this.view.whenLayerView(e),a=await e.applyEdits(t);return await d(r,"updating"),a}))}_queueOperation(e){this.activityQueue.push(e),this.notifyChange("syncing");const t=(e,t)=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)};return e().then((({addFeatureResults:e,deleteFeatureResults:t,updateFeatureResults:r})=>{const a=e.find((e=>!!e.error))||r.find((e=>!!e.error))||t.find((e=>!!e.error));if(a)throw a.error})).catch((r=>{j("editing:operation-error","An error occurred.",{error:r});const a={error:r,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])})).then((()=>{t(e,this.activityQueue),this.notifyChange("syncing")}))}};e([p({readOnly:!0})],V.prototype,"activeWorkflow",void 0),e([p({readOnly:!0})],V.prototype,"activityQueue",void 0),e([p({value:[...F]})],V.prototype,"allowedWorkflows",null),e([p({readOnly:!0})],V.prototype,"canCreate",null),e([p({readOnly:!0})],V.prototype,"canUpdate",null),e([p({readOnly:!0})],V.prototype,"editableItems",null),e([p({readOnly:!0})],V.prototype,"failures",void 0),e([p()],V.prototype,"attachmentsViewModel",void 0),e([p()],V.prototype,"featureFormViewModel",void 0),e([p()],V.prototype,"featureTemplatesViewModel",void 0),e([p()],V.prototype,"layerInfos",void 0),e([p()],V.prototype,"sketchViewModel",void 0),e([c("sketchViewModel.snappingOptions")],V.prototype,"snappingOptions",void 0),e([p()],V.prototype,"spinnerViewModel",void 0),e([p()],V.prototype,"state",null),e([p({readOnly:!0})],V.prototype,"syncing",null),e([p()],V.prototype,"view",null),V=e([w(C)],V);const U=V;export{U as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import r from"../../core/Error.js";import a from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import i from"../../core/Logger.js";import{on as s,init as n,watch as l,whenFalseOnce as c}from"../../core/watchUtils.js";import{aliasOf as d}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../layers/GraphicsLayer.js";import f from"../../views/interactive/snapping/SnappingOptions.js";import h from"../Attachments/AttachmentsViewModel.js";import k from"./CreateFeaturesWorkflow.js";import m from"./CreateWorkflow.js";import{workflowDeprecation as y}from"./deprecationUtils.js";import W from"./UpdateWorkflow.js";import v from"../FeatureForm/FeatureFormViewModel.js";import g from"../FeatureTemplates/FeatureTemplatesViewModel.js";import _ from"../Sketch/SketchViewModel.js";import C from"../Spinner/SpinnerViewModel.js";const F="esri.widgets.Editor.EditorViewModel",b=i.getLogger(F),j=["create","create-features","update"];function A(e,t,a){b.error(new r(e,t,a))}function M(e,t){return e&&e.find((e=>e.layer===t))}let V=class extends(o(a.EventedAccessor)){constructor(e){super(e),this._sketchGraphicsLayer=new w({listMode:"hide",internal:!0}),this.activeWorkflow=null,this.activityQueue=[],this.failures=[],this.attachmentsViewModel=new h({abilities:{editing:!0}}),this.featureFormViewModel=new v,this.featureTemplatesViewModel=new g,this.layerInfos=null,this.sketchViewModel=new _({layer:this._sketchGraphicsLayer}),this.snappingOptions=new f,this.spinnerViewModel=new C}initialize(){this.handles.add([s(this,"activeWorkflow","cancel",(()=>this.emit("workflow-cancel"))),s(this,"activeWorkflow","commit",(()=>this.emit("workflow-commit"))),n(this,"view.map",(e=>{e&&e.add(this._sketchGraphicsLayer)})),l(this,"editableItems",(()=>{const{activeWorkflow:e}=this;if(this.refreshCreationTemplates(),!e)return;const{stepId:t}=e;"create"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdate||"awaiting-update-feature-candidate"===t&&!e.data.candidates.some((e=>{const t=this.editableItems.find((t=>t.layer===e.layer));return t&&t.supports.indexOf("update")>-1})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}))])}destroy(){this._cancelWorkflow().then((()=>{var e;null!=(e=this.view)&&e.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null}))}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(e){e&&0!==e.length||(e=[...j]),this._set("allowedWorkflows",e)}get canCreate(){return this.editableItems.some((e=>e.supports.includes("create")))}get canUpdate(){return this.editableItems.some((e=>e.supports.includes("update")))}get editableItems(){var e,r,a;const o=null==(e=this.view)?void 0:e.allLayerViews;if(!o)return new t;const i=new Set(null==(r=this.view)||null==(a=r.map)?void 0:a.editableLayers);return o.filter((e=>i.has(e.layer))).map((e=>{const{layer:t,suspended:r}=e,{data:a,operations:o}=t.capabilities,i=M(this.layerInfos,t),s="supportsAttachment"in a&&a.supportsAttachment&&(!i||!1!==i.allowAttachments);if(r)return{hasAttachments:s,layer:t,supports:[]};const n=[];return o.supportsAdd&&(this.allowedWorkflows.includes("create")||this.allowedWorkflows.includes("create-features"))&&(!i||!1!==i.enabled&&!1!==i.addEnabled)&&n.push("create"),o.supportsUpdate&&this.allowedWorkflows.includes("update")&&(!i||!1!==i.enabled&&!1!==i.updateEnabled)&&n.push("update"),!1!==(i&&i.deleteEnabled)&&o.supportsDelete&&n.push("delete"),{hasAttachments:s,layer:t,supports:n}})).reverse()}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this;return t?t.stepId:"ready"}get syncing(){return this.activityQueue.length>0}set view(e){this.sketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}async startCreateWorkflowAtFeatureTypeSelection(){if(y(b,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),!this.canCreate)return void A("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(e){if(y(b,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),!this.canCreate)return void A("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("awaiting-feature-to-create");t.data.creationInfo=e,await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(!this.canCreate)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(e,t);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(e){if(y(b,"startCreateWorkflowAtFeatureEdit"),!this.canCreate)return void A("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("editing-new-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureSelection(){if(!this.canUpdate)return void A("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(!this.canUpdate)return void A("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureEdit(e){if(!this.canUpdate)return void A("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async deleteFeatureFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?(await this._delete(e.data.edits.feature),await e.reset()):A("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warn:!0,...e})}refreshCreationTemplates(){const e=[];for(const{layer:t,supports:r}of this.editableItems)t.loaded&&r.includes("create")&&e.push(t);this.featureTemplatesViewModel.layers=e}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e&&e.warn&&A("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await t.cancel(e);await t.cancel(e),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(e,t){return k.create(this,e,t,((e,t)=>this._applyEdits(e,t)))}_createCreateWorkflow(e){return m.create(this,e,((e,t)=>this._applyEdits(e,t)))}_createUpdateWorkflow(e){return W.create(this,e,((e,t)=>this._applyEdits(e,t)))}async _delete(e){const t=e.sourceLayer;"applyEdits"in t&&await this._applyEdits(t,{deleteFeatures:[e]})}async _applyEdits(e,t){await this._queueOperation((async()=>{const r=await this.view.whenLayerView(e),a=await e.applyEdits(t);return await c(r,"updating"),a}))}_queueOperation(e){this.activityQueue.push(e),this.notifyChange("syncing");const t=(e,t)=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)};return e().then((({addFeatureResults:e,deleteFeatureResults:t,updateFeatureResults:r})=>{const a=e.find((e=>!!e.error))||r.find((e=>!!e.error))||t.find((e=>!!e.error));if(a)throw a.error})).catch((r=>{A("editing:operation-error","An error occurred.",{error:r});const a={error:r,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])})).then((()=>{t(e,this.activityQueue),this.notifyChange("syncing")}))}};e([p({readOnly:!0})],V.prototype,"activeWorkflow",void 0),e([p({readOnly:!0})],V.prototype,"activityQueue",void 0),e([p({value:[...j]})],V.prototype,"allowedWorkflows",null),e([p({readOnly:!0})],V.prototype,"canCreate",null),e([p({readOnly:!0})],V.prototype,"canUpdate",null),e([p({readOnly:!0})],V.prototype,"editableItems",null),e([p({readOnly:!0})],V.prototype,"failures",void 0),e([p()],V.prototype,"attachmentsViewModel",void 0),e([p()],V.prototype,"featureFormViewModel",void 0),e([p()],V.prototype,"featureTemplatesViewModel",void 0),e([p()],V.prototype,"layerInfos",void 0),e([p()],V.prototype,"sketchViewModel",void 0),e([d("sketchViewModel.snappingOptions")],V.prototype,"snappingOptions",void 0),e([p()],V.prototype,"spinnerViewModel",void 0),e([p()],V.prototype,"state",null),e([p({readOnly:!0})],V.prototype,"syncing",null),e([p()],V.prototype,"view",null),V=e([u(F)],V);const U=V;export{U as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
+ */
5
+ import{deprecated as e}from"../../core/deprecate.js";function t(t,r,s){e(t,"`"+r+"` is deprecated, because it instantiates the deprecated class 'esri.widgets.Editor.CreateWorkflow'",{replacement:s,version:"4.23",see:"https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor-CreateFeaturesWorkflow.html"})}export{t as workflowDeprecation};
package/widgets/Editor.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import{isSome as s}from"../core/maybe.js";import{watch as i}from"../core/reactiveUtils.js";import{init as a,on as n,watch as r,whenNot as o}from"../core/watchUtils.js";import{aliasOf as l}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as h}from"../layers/support/fieldUtils.js";import m from"../views/interactive/snapping/SnappingOptions.js";import u from"./Attachments.js";import g from"./FeatureForm.js";import v from"./FeatureTemplates.js";import _ from"./Spinner.js";import w from"./Widget.js";import f from"./Editor/EditorViewModel.js";import{ItemList as k}from"./FeatureTemplates/ItemList.js";import{Heading as y,incrementHeadingLevel as b}from"./support/Heading.js";import C from"./support/SnappingControls.js";import{accessibleHandler as M}from"./support/decorators/accessibleHandler.js";import{messageBundle as A}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{vmEvent as F}from"./support/decorators/vmEvent.js";import{tsx as W}from"./support/jsxFactory.js";import{classes as T}from"./support/widgetUtils.js";import{substitute as S}from"../intl/substitute.js";const B={base:"esri-editor esri-widget esri-widget--panel",scroller:"esri-editor__scroller",content:"esri-editor__content",contentGroup:"esri-editor__content-group",message:"esri-editor__message",controls:"esri-editor__controls",progressBar:"esri-editor__progress-bar",promptContainer:"esri-editor__prompt",promptHeader:"esri-editor__prompt__header",promptHeading:"esri-editor__prompt__header__heading",promptMessage:"esri-editor__prompt__message",promptDivider:"esri-editor__prompt__divider",promptActions:"esri-editor__prompt__actions",promptOption:"esri-editor__prompt__option",promptOptionPrimary:"esri-editor__prompt__option--primary",promptOptionNegative:"esri-editor__prompt__option--negative",promptOptionPositive:"esri-editor__prompt__option--positive",controlButton:"esri-editor__control-button",overlay:"esri-editor__overlay",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary",input:"esri-input",interactive:"esri-interactive",select:"esri-select",panelToolbar:"esri-editor__panel-toolbar",panelToolbarSnappingButton:"esri-editor__panel-toolbar__snapping-button",panelContent:"esri-editor__panel-content",panelContentSection:"esri-editor__panel-content--section",updateFeaturesActionButtons:"esri-editor__update-features-action-buttons",updateFeaturesActionButtonsButton:"esri-editor__update-features-action-buttons--button",featureTemplatesContainer:"esri-editor__feature-templates-container",snappingControlsPopover:"esri-editor__snapping-controls-popover",scrimOverlay:"esri-editor__scrim-overlay"},E={undoRedoButtons:!1};function P(e){e.focus()}let j=class extends(t(w)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new g,this._stateStack=[],this._attachments=new u({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new v({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new _,this._snappingPopover=null,this.activeWorkflow=null,this.allowedWorkflows=null,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=B.widgetIcon,this.label=void 0,this.layerInfos=null,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.snappingOptions=new m,this.supportingWidgetDefaults=null,this.view=null,this.viewModel=new f,this.visibleElements={...E},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new C({snappingOptions:t,view:e,visibleElements:{header:!1}}),this.own([a(this,"headingLevel",(e=>{this._featureForm.headingLevel=b(e),this._featureTemplates.headingLevel=b(e)})),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))),i((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),a(this,"viewModel",(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null})),a(this,"view",((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})})),n(this,"viewModel.sketchViewModel","create",(()=>{this.scheduleRender()})),n(this,"viewModel.activeWorkflow","cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),a(this,"supportingWidgetDefaults",(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))})),r(this,"_attachments.error",(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),r(this,"viewModel.failures",(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:i,cancel:a}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(a(),this._prompt=null)}}}})),r(this,"viewModel.state",(e=>{"awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1)})),r(this,["_attachments.selectedFile","_attachments.submitting"],(()=>this.scheduleRender())),o(this,"viewModel.activeWorkflow",(()=>this._featureTemplates.filterText=""))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-menu.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-loader.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-popover-manager.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js"),import("@esri/calcite-components/dist/components/calcite-tooltip-manager.js")])}castVisibleElements(e){return{...E,...e}}startCreateWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflow(e,"creating-features")}startCreateWorkflowAtFeatureEdit(e){return this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:i}=this;if(!i)return W("div",{class:B.base});const{state:a}=i,n=s(t)?W("calcite-scrim",null,this.renderPrompt(t)):null;return W("div",{class:B.base},i.syncing||e.submitting?this.renderProgressBar():null,W("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(a)),n)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return W("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_handleBack:n,_snappingControls:r,viewModel:{sketchViewModel:o}}=this;return W(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:n,heading:i.selectTemplate,headingLevel:s,messages:i,messagesCommon:a,sketchViewModel:o,snappingControls:r},this._featureTemplates.render())}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:i,messagesCommon:a,headingLevel:n,_handleBack:r,_snappingControls:o,viewModel:l}=this,{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing||c.inputFields.length>0&&!c.submittable,h="update"===t.type?i.editFeature:i.createFeatures,m="update"===t.type?a.update:a.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g=[{label:"create-features"===t.type&&t.numPendingFeatures>1?S(i.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave}];let v=!1;return"update"===t.type&&(t.data.editableItem.hasAttachments&&(v=!0),t.data.editableItem.supports.includes("delete")&&g.push({label:a.delete,type:"tertiary",clickHandler:this._handleDelete})),W(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:n,showContentScrim:u,handleBack:r,messages:i,messagesCommon:a,sketchViewModel:d,snappingControls:o},W("div",{class:B.panelContentSection},W("div",{class:B.contentGroup},c.inputFields.length>0?this._featureForm.render():this.renderMessage(S(i.clickToFinishTemplate,{button:m})),v?W("div",{key:"attachments"},W("div",null,i.attachments),this._attachments.render()):null)),W("div",{class:this._prompt?"":B.scrimOverlay},this.renderControls(g)))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:n,messagesCommon:r,_snappingControls:o,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?r.cancel:r.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd}];return W(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:n.addAttachment,headingLevel:a,handleBack:i,messages:n,messagesCommon:r,sketchViewModel:l,snappingControls:o},W("div",{class:this.classes(B.content,B.scroller)},t.render()),this.renderControls(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:n,messagesCommon:r,_snappingControls:o,viewModel:{sketchViewModel:l}}=this,d=[{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate},{label:r.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete}];return W(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:n.editAttachment,headingLevel:a,handleBack:i,messages:n,messagesCommon:r,sketchViewModel:l,snappingControls:o},W("div",{class:this.classes(B.content,B.scroller)},t.render()),this.renderControls(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:n,_snappingControls:r,viewModel:{sketchViewModel:o}}=this;return W(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:a.selectFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:n,sketchViewModel:o,snappingControls:r},W("div",{class:this.classes(B.content,B.scroller)},this.renderMessage(a.selectFeatureToEdit)))}renderMessage(e){return W("div",{class:B.message},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:n,_snappingControls:r,viewModel:o}=this,{sketchViewModel:l}=o,d=o.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return W(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:a.placeFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:n,sketchViewModel:l,snappingControls:r},W("div",{class:this.classes(B.content,B.scroller)},this.renderMessage(h)))}renderControls(e){return W("div",{class:B.controls,key:"controls"},e.map((({disabled:e=!1,label:t,type:s,clickHandler:i},a)=>this.renderButton({label:t,class:this.classes(B.controlButton,B.button,"secondary"===s?B.buttonSecondary:"tertiary"===s?B.buttonTertiary:null,e?B.buttonDisabled:null),disabled:e,clickHandler:i,key:a}))))}renderPrompt({title:e,message:t,context:s,actions:i}){const a=!!i.secondary,n=W("calcite-button",{appearance:"solid",color:"danger"===s?"red":"blue",width:a?"half":"full",onclick:i.primary.action,key:"prompt-primary-button",afterCreate:P},i.primary.label),r=a?W("calcite-button",{appearance:"clear",color:"danger"===s?"red":"blue",width:"half",onclick:i.secondary.action,key:"prompt-secondary-button"},i.secondary.label):null;return W("div",{class:`${B.promptContainer}--${s}`},W("div",{class:B.promptHeader},W("calcite-icon",{icon:"exclamation-mark-triangle"}),W(y,{class:B.promptHeading,level:this.headingLevel},e)),W("div",{class:B.promptMessage},t),W("div",{class:B.promptDivider}),W("div",{class:B.promptActions},r,n))}renderProgressBar(){return W("div",{class:this.classes(B.progressBar),key:"progress-bar"})}renderButton(e){return W("button",{class:e.class,disabled:e.disabled,key:e.key,onclick:e.clickHandler,type:"button"},e.label)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_snappingControls:n,viewModel:{sketchViewModel:r}}=this;return W(t,{active:this.isPanelActive(e),key:"landing-panel",heading:i.widgetLabel,headingLevel:s,showBackButton:!1,messages:i,messagesCommon:a,sketchViewModel:r,snappingControls:n},W("div",{key:"edit-actions",class:B.panelContentSection},this.renderUpdateActions()),W("div",{key:"create-actions",class:B.panelContentSection},this.renderCreateActions()))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return W("div",null,W(y,{level:b(this.headingLevel)},e.editFeatures),W("div",{class:B.updateFeaturesActionButtons},W("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:B.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{messages:e}=this;return W("div",null,W(y,{level:b(this.headingLevel)},e.createFeatures),W("div",{key:"templates",class:B.featureTemplatesContainer},this._featureTemplates.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:n,messagesTemplates:r,_snappingControls:o,viewModel:{editableItems:l,sketchViewModel:d}}=this,c=this._assertActiveUpdateWorkflow().data.candidates,p=S(a.multipleFeaturesTemplate,{total:c.length}),h=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,i=this._filterText.toLowerCase(),{title:a}=s.layer,n=this.viewModel.editableItems.find((e=>e.layer===s.layer));return n.supports.indexOf("update")>-1&&(!i||t.toLowerCase().indexOf(i)>-1||a.toLowerCase().indexOf(i)>-1)})).forEach((e=>{m++;const t=e.data.layer;h.has(t)?h.get(t).items.push(e):h.set(t,{id:`${t.id}`,label:t.title,items:[e]})}));const u=l.filter((({layer:e})=>h.has(e))).map((({layer:e})=>h.get(e))).toArray(),g=m>10||this._filterText.length>0;return W(t,{active:this.isPanelActive(e),key:"feature-list",heading:p,headingLevel:i,handleBack:s,messages:a,messagesCommon:n,sketchViewModel:d,snappingControls:o},k({id:this.id,enableListScroll:!1,filterEnabled:g,filterText:this._filterText,items:u,messages:{filterPlaceholder:r.filterPlaceholder,noItems:r.noItems,noMatches:r.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e}))}EditorPanel(e,...t){const{active:s,handleBack:i,heading:a,headingLevel:n,key:r,messages:o,messagesCommon:l,showBackButton:d,showContentScrim:c,sketchViewModel:p,snappingControls:h}=e;return W("calcite-panel",{bind:this,key:r,heading:a,headingLevel:n,showBackButton:null==d||d,beforeBack:null!=i?i:null,onCalcitePanelScroll:this._onSnappingPopoverPanelScroll},W("calcite-popover-manager",{autoClose:s,class:B.panelToolbar},W("calcite-popover",{afterCreate:this._afterSnappingPopoverCreated,afterUpdate:this._afterSnappingPopoverUpdated,bind:this,label:o.snappingSettings,heading:o.snappingSettings,"reference-element":`${r}__snappingButton`,"overlay-positioning":"fixed"},W("div",{class:B.snappingControlsPopover},h.render())),W("calcite-button",{id:`${r}__snappingButton`,text:o.snapping,appearance:"transparent",color:"neutral",alignment:"icon-end-space-between","icon-start":"vertex-gps","icon-end":"caret-down",width:"full",class:B.panelToolbarSnappingButton},o.snapping),this.visibleElements.undoRedoButtons?[W("calcite-button",{key:"undo-button",text:l.undo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"undo",scale:"l",disabled:!p.canUndo(),onclick:p.undo.bind(p)}),W("calcite-button",{key:"redo-button",text:l.redo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"redo",scale:"l",disabled:!p.canRedo(),onclick:p.redo.bind(p)})]:null),W("div",{class:T(B.panelContent,B.scroller)},t,c?W("calcite-scrim",null):null))}_onSnappingPopoverPanelScroll(){var e;null!=(e=this._snappingPopover)&&e.open&&this._snappingPopover.toggle()}_afterSnappingPopoverCreated(e){this._snappingPopover=e}_afterSnappingPopoverUpdated(e){this._snappingPopover=e}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const i=t.geometry,a="polygon"===e?"rings":"paths",[n]=i[a];return"polygon"===e&&n<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:i}=e,a=h(t);return a&&i[a]&&`${i[a]}`||S(this.messages.untitledFeatureTemplate,{id:i[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){this.viewModel.featureFormViewModel.validateContingencyConstraints(this.viewModel.featureFormViewModel.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow.commit()}_handleAttachmentAdd(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.addAttachment().then((()=>t.previous()))}_handleAttachmentUpdate(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.updateAttachment().then((()=>t.previous()))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null}))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(){const{messages:e}=this,t=this.activeWorkflow,s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&t.data.edits.modified){const{type:i}=t,a="create"===i?e.cancelAddWarningMessage:e.cancelEditWarningMessage,n="create"===i?e.cancelAddTitle:e.cancelEditTitle,r="create"===i?e.continueAdding:e.continueEditing,o="create"===i?e.discardFeature:e.discardEdits;return this._prompt={title:n,message:a,context:"danger",actions:{primary:{label:o,action:()=>{s(),this._prompt=null}},secondary:{label:r,action:()=>this._prompt=null}}},this.scheduleRender(),Promise.reject()}s()}_assertActiveCreateWorkflow(){const{type:e}=this.viewModel.activeWorkflow;if("create"===e||"create-features"===e)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){if("update"===this.viewModel.activeWorkflow.type)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be an UpdateWorkflow")}};e([c()],j.prototype,"_attachments",void 0),e([l("viewModel.activeWorkflow")],j.prototype,"activeWorkflow",void 0),e([l("viewModel.allowedWorkflows")],j.prototype,"allowedWorkflows",void 0),e([c()],j.prototype,"useDeprecatedCreateWorkflow",void 0),e([c()],j.prototype,"headingLevel",void 0),e([c()],j.prototype,"iconClass",void 0),e([c({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],j.prototype,"label",void 0),e([l("viewModel.layerInfos")],j.prototype,"layerInfos",void 0),e([c(),A("esri/widgets/Editor/t9n/Editor")],j.prototype,"messages",void 0),e([c(),A("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([c(),A("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],j.prototype,"messagesTemplates",void 0),e([l("viewModel.snappingOptions")],j.prototype,"snappingOptions",void 0),e([c()],j.prototype,"supportingWidgetDefaults",void 0),e([l("viewModel.view")],j.prototype,"view",void 0),e([c(),F(["workflow-cancel","workflow-commit"])],j.prototype,"viewModel",void 0),e([c()],j.prototype,"visibleElements",void 0),e([d("visibleElements")],j.prototype,"castVisibleElements",null),e([M()],j.prototype,"_handleDelete",null),e([M()],j.prototype,"_handleAttachmentAdd",null),e([M()],j.prototype,"_handleAttachmentUpdate",null),e([M()],j.prototype,"_handleAttachmentDelete",null),e([M()],j.prototype,"_handleAdd",null),e([M()],j.prototype,"_handleEdit",null),e([M()],j.prototype,"_handleDone",null),j=e([p("esri.widgets.Editor")],j);const L=j;export{L as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as i}from"../core/maybe.js";import{watch as a}from"../core/reactiveUtils.js";import{init as r,on as o,watch as n,whenNot as l}from"../core/watchUtils.js";import{aliasOf as d}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as c}from"../core/accessorSupport/decorators/cast.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import u from"../views/interactive/snapping/SnappingOptions.js";import g from"./Attachments.js";import v from"./FeatureForm.js";import _ from"./FeatureTemplates.js";import w from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as k}from"./Editor/deprecationUtils.js";import y from"./Editor/EditorViewModel.js";import{ItemList as b}from"./FeatureTemplates/ItemList.js";import{Heading as C,incrementHeadingLevel as M}from"./support/Heading.js";import F from"./support/SnappingControls.js";import{accessibleHandler as A}from"./support/decorators/accessibleHandler.js";import{messageBundle as W}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as S}from"./support/jsxFactory.js";import{classes as E}from"./support/widgetUtils.js";import{substitute as B}from"../intl/substitute.js";const P={base:"esri-editor esri-widget esri-widget--panel",scroller:"esri-editor__scroller",content:"esri-editor__content",contentGroup:"esri-editor__content-group",message:"esri-editor__message",controls:"esri-editor__controls",progressBar:"esri-editor__progress-bar",promptContainer:"esri-editor__prompt",promptHeader:"esri-editor__prompt__header",promptHeading:"esri-editor__prompt__header__heading",promptMessage:"esri-editor__prompt__message",promptDivider:"esri-editor__prompt__divider",promptActions:"esri-editor__prompt__actions",promptOption:"esri-editor__prompt__option",promptOptionPrimary:"esri-editor__prompt__option--primary",promptOptionNegative:"esri-editor__prompt__option--negative",promptOptionPositive:"esri-editor__prompt__option--positive",controlButton:"esri-editor__control-button",overlay:"esri-editor__overlay",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary",input:"esri-input",interactive:"esri-interactive",select:"esri-select",panelToolbar:"esri-editor__panel-toolbar",panelToolbarSnappingButton:"esri-editor__panel-toolbar__snapping-button",panelContent:"esri-editor__panel-content",panelContentSection:"esri-editor__panel-content--section",updateFeaturesActionButtons:"esri-editor__update-features-action-buttons",updateFeaturesActionButtonsButton:"esri-editor__update-features-action-buttons--button",featureTemplatesContainer:"esri-editor__feature-templates-container",snappingControlsPopover:"esri-editor__snapping-controls-popover",scrimOverlay:"esri-editor__scrim-overlay"},j={undoRedoButtons:!1};function L(e){e.focus()}const x="esri.widgets.Editor",U=s.getLogger(x);let V=class extends(t(f)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new v,this._stateStack=[],this._attachments=new g({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new _({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new w,this._snappingPopover=null,this.activeWorkflow=null,this.allowedWorkflows=null,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=P.widgetIcon,this.label=void 0,this.layerInfos=null,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.snappingOptions=new u,this.supportingWidgetDefaults=null,this.view=null,this.viewModel=new y,this.visibleElements={...j},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new F({snappingOptions:t,view:e,visibleElements:{header:!1}}),this.own([r(this,"headingLevel",(e=>{this._featureForm.headingLevel=M(e),this._featureTemplates.headingLevel=M(e)})),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))),a((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),r(this,"viewModel",(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null})),r(this,"view",((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})})),o(this,"viewModel.sketchViewModel","create",(()=>{this.scheduleRender()})),o(this,"viewModel.activeWorkflow","cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),r(this,"supportingWidgetDefaults",(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))})),n(this,"_attachments.error",(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),n(this,"viewModel.failures",(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:i,cancel:a}]=e;this._prompt={title:t.errorWarningTitle,message:B(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(a(),this._prompt=null)}}}})),n(this,"viewModel.state",(e=>{"awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1)})),n(this,["_attachments.selectedFile","_attachments.submitting"],(()=>this.scheduleRender())),l(this,"viewModel.activeWorkflow",(()=>this._featureTemplates.filterText=""))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-menu.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-loader.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-popover-manager.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js"),import("@esri/calcite-components/dist/components/calcite-tooltip-manager.js")])}castVisibleElements(e){return{...j,...e}}startCreateWorkflowAtFeatureTypeSelection(){return k(U,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return k(U,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return k(U,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return S("div",{class:P.base});const{state:a}=s,r=i(t)?S("calcite-scrim",null,this.renderPrompt(t)):null;return S("div",{class:P.base},s.syncing||e.submitting?this.renderProgressBar():null,S("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(a)),r)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return S("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_handleBack:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return S(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:r,heading:i.selectTemplate,headingLevel:s,messages:i,messagesCommon:a,sketchViewModel:n,snappingControls:o},this._featureTemplates.render())}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:i,messagesCommon:a,headingLevel:r,_handleBack:o,_snappingControls:n,viewModel:l}=this,{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing||c.inputFields.length>0&&!c.submittable,h="update"===t.type?i.editFeature:i.createFeatures,m="update"===t.type?a.update:a.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g=[{label:"create-features"===t.type&&t.numPendingFeatures>1?B(i.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave}];let v=!1;return"update"===t.type&&(t.data.editableItem.hasAttachments&&(v=!0),t.data.editableItem.supports.includes("delete")&&g.push({label:a.delete,type:"tertiary",clickHandler:this._handleDelete})),S(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:r,showContentScrim:u,handleBack:o,messages:i,messagesCommon:a,sketchViewModel:d,snappingControls:n},S("div",{class:P.panelContentSection},S("div",{class:P.contentGroup},c.inputFields.length>0?this._featureForm.render():this.renderMessage(B(i.clickToFinishTemplate,{button:m})),v?S("div",{key:"attachments"},S("div",null,i.attachments),this._attachments.render()):null)),S("div",{class:this._prompt?"":P.scrimOverlay},this.renderControls(g)))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd}];return S(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:r.addAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},S("div",{class:this.classes(P.content,P.scroller)},t.render()),this.renderControls(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:o.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate},{label:o.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete}];return S(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:r.editAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},S("div",{class:this.classes(P.content,P.scroller)},t.render()),this.renderControls(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return S(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:a.selectFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:n,snappingControls:o},S("div",{class:this.classes(P.content,P.scroller)},this.renderMessage(a.selectFeatureToEdit)))}renderMessage(e){return S("div",{class:P.message},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:n}=this,{sketchViewModel:l}=n,d=n.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return S(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:a.placeFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:l,snappingControls:o},S("div",{class:this.classes(P.content,P.scroller)},this.renderMessage(h)))}renderControls(e){return S("div",{class:P.controls,key:"controls"},e.map((({disabled:e=!1,label:t,type:s,clickHandler:i},a)=>this.renderButton({label:t,class:this.classes(P.controlButton,P.button,"secondary"===s?P.buttonSecondary:"tertiary"===s?P.buttonTertiary:null,e?P.buttonDisabled:null),disabled:e,clickHandler:i,key:a}))))}renderPrompt({title:e,message:t,context:s,actions:i}){const a=!!i.secondary,r=S("calcite-button",{appearance:"solid",color:"danger"===s?"red":"blue",width:a?"half":"full",onclick:i.primary.action,key:"prompt-primary-button",afterCreate:L},i.primary.label),o=a?S("calcite-button",{appearance:"clear",color:"danger"===s?"red":"blue",width:"half",onclick:i.secondary.action,key:"prompt-secondary-button"},i.secondary.label):null;return S("div",{class:`${P.promptContainer}--${s}`},S("div",{class:P.promptHeader},S("calcite-icon",{icon:"exclamation-mark-triangle"}),S(C,{class:P.promptHeading,level:this.headingLevel},e)),S("div",{class:P.promptMessage},t),S("div",{class:P.promptDivider}),S("div",{class:P.promptActions},o,r))}renderProgressBar(){return S("div",{class:this.classes(P.progressBar),key:"progress-bar"})}renderButton(e){return S("button",{class:e.class,disabled:e.disabled,key:e.key,onclick:e.clickHandler,type:"button"},e.label)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_snappingControls:r,viewModel:{sketchViewModel:o}}=this;return S(t,{active:this.isPanelActive(e),key:"landing-panel",heading:i.widgetLabel,headingLevel:s,showBackButton:!1,messages:i,messagesCommon:a,sketchViewModel:o,snappingControls:r},S("div",{key:"edit-actions",class:P.panelContentSection},this.renderUpdateActions()),S("div",{key:"create-actions",class:P.panelContentSection},this.renderCreateActions()))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return S("div",null,S(C,{level:M(this.headingLevel)},e.editFeatures),S("div",{class:P.updateFeaturesActionButtons},S("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:P.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{messages:e}=this;return S("div",null,S(C,{level:M(this.headingLevel)},e.createFeatures),S("div",{key:"templates",class:P.featureTemplatesContainer},this._featureTemplates.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,messagesTemplates:o,_snappingControls:n,viewModel:{editableItems:l,sketchViewModel:d}}=this,c=this._assertActiveUpdateWorkflow().data.candidates,p=B(a.multipleFeaturesTemplate,{total:c.length}),h=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,i=this._filterText.toLowerCase(),{title:a}=s.layer,r=this.viewModel.editableItems.find((e=>e.layer===s.layer));return r.supports.indexOf("update")>-1&&(!i||t.toLowerCase().indexOf(i)>-1||a.toLowerCase().indexOf(i)>-1)})).forEach((e=>{m++;const t=e.data.layer;h.has(t)?h.get(t).items.push(e):h.set(t,{id:`${t.id}`,label:t.title,items:[e]})}));const u=l.filter((({layer:e})=>h.has(e))).map((({layer:e})=>h.get(e))).toArray(),g=m>10||this._filterText.length>0;return S(t,{active:this.isPanelActive(e),key:"feature-list",heading:p,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:d,snappingControls:n},b({id:this.id,enableListScroll:!1,filterEnabled:g,filterText:this._filterText,items:u,messages:{filterPlaceholder:o.filterPlaceholder,noItems:o.noItems,noMatches:o.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e}))}EditorPanel(e,...t){const{active:s,handleBack:i,heading:a,headingLevel:r,key:o,messages:n,messagesCommon:l,showBackButton:d,showContentScrim:c,sketchViewModel:p,snappingControls:h}=e;return S("calcite-panel",{bind:this,key:o,heading:a,headingLevel:r,showBackButton:null==d||d,beforeBack:null!=i?i:null,onCalcitePanelScroll:this._onSnappingPopoverPanelScroll},S("calcite-popover-manager",{autoClose:s,class:P.panelToolbar},S("calcite-popover",{afterCreate:this._afterSnappingPopoverCreated,afterUpdate:this._afterSnappingPopoverUpdated,bind:this,label:n.snappingSettings,heading:n.snappingSettings,"reference-element":`${o}__snappingButton`,"overlay-positioning":"fixed"},S("div",{class:P.snappingControlsPopover},h.render())),S("calcite-button",{id:`${o}__snappingButton`,text:n.snapping,appearance:"transparent",color:"neutral",alignment:"icon-end-space-between","icon-start":"vertex-gps","icon-end":"caret-down",width:"full",class:P.panelToolbarSnappingButton},n.snapping),this.visibleElements.undoRedoButtons?[S("calcite-button",{key:"undo-button",text:l.undo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"undo",scale:"l",disabled:!p.canUndo(),onclick:p.undo.bind(p)}),S("calcite-button",{key:"redo-button",text:l.redo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"redo",scale:"l",disabled:!p.canRedo(),onclick:p.redo.bind(p)})]:null),S("div",{class:E(P.panelContent,P.scroller)},t,c?S("calcite-scrim",null):null))}_onSnappingPopoverPanelScroll(){var e;null!=(e=this._snappingPopover)&&e.open&&this._snappingPopover.toggle()}_afterSnappingPopoverCreated(e){this._snappingPopover=e}_afterSnappingPopoverUpdated(e){this._snappingPopover=e}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const i=t.geometry,a="polygon"===e?"rings":"paths",[r]=i[a];return"polygon"===e&&r<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:i}=e,a=m(t);return a&&i[a]&&`${i[a]}`||B(this.messages.untitledFeatureTemplate,{id:i[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){this.viewModel.featureFormViewModel.validateContingencyConstraints(this.viewModel.featureFormViewModel.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow.commit()}_handleAttachmentAdd(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.addAttachment().then((()=>t.previous()))}_handleAttachmentUpdate(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.updateAttachment().then((()=>t.previous()))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null}))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(){const{messages:e}=this,t=this.activeWorkflow,s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&t.data.edits.modified){const{type:i}=t,a="create"===i?e.cancelAddWarningMessage:e.cancelEditWarningMessage,r="create"===i?e.cancelAddTitle:e.cancelEditTitle,o="create"===i?e.continueAdding:e.continueEditing,n="create"===i?e.discardFeature:e.discardEdits;return this._prompt={title:r,message:a,context:"danger",actions:{primary:{label:n,action:()=>{s(),this._prompt=null}},secondary:{label:o,action:()=>this._prompt=null}}},this.scheduleRender(),Promise.reject()}s()}_assertActiveCreateWorkflow(){const{type:e}=this.viewModel.activeWorkflow;if("create"===e||"create-features"===e)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){if("update"===this.viewModel.activeWorkflow.type)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be an UpdateWorkflow")}};e([p()],V.prototype,"_attachments",void 0),e([d("viewModel.activeWorkflow")],V.prototype,"activeWorkflow",void 0),e([d("viewModel.allowedWorkflows")],V.prototype,"allowedWorkflows",void 0),e([p()],V.prototype,"useDeprecatedCreateWorkflow",void 0),e([p()],V.prototype,"headingLevel",void 0),e([p()],V.prototype,"iconClass",void 0),e([p({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],V.prototype,"label",void 0),e([d("viewModel.layerInfos")],V.prototype,"layerInfos",void 0),e([p(),W("esri/widgets/Editor/t9n/Editor")],V.prototype,"messages",void 0),e([p(),W("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([p(),W("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],V.prototype,"messagesTemplates",void 0),e([d("viewModel.snappingOptions")],V.prototype,"snappingOptions",void 0),e([p()],V.prototype,"supportingWidgetDefaults",void 0),e([d("viewModel.view")],V.prototype,"view",void 0),e([p(),T(["workflow-cancel","workflow-commit"])],V.prototype,"viewModel",void 0),e([p()],V.prototype,"visibleElements",void 0),e([c("visibleElements")],V.prototype,"castVisibleElements",null),e([A()],V.prototype,"_handleDelete",null),e([A()],V.prototype,"_handleAttachmentAdd",null),e([A()],V.prototype,"_handleAttachmentUpdate",null),e([A()],V.prototype,"_handleAttachmentDelete",null),e([A()],V.prototype,"_handleAdd",null),e([A()],V.prototype,"_handleEdit",null),e([A()],V.prototype,"_handleDone",null),V=e([h(x)],V);const D=V;export{D 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.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{eventKey as t}from"../../core/events.js";import{init as i}from"../../core/watchUtils.js";import{aliasOf as r}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import n from"./FeatureMedia/FeatureMediaViewModel.js";import l from"./support/FeatureElementInfo.js";import{shouldOpenInNewTab as d}from"./support/featureUtils.js";import{loadChartsModule as c,getColorSet as m}from"../support/chartUtils.js";import{isRTL as u}from"../support/widgetUtils.js";import{messageBundle as h}from"../support/decorators/messageBundle.js";import"../../core/Logger.js";import{tsx as p}from"../support/jsxFactory.js";import{isDarkTheme as f}from"../support/widgetThemeUtils.js";const v={base:"esri-feature-media",mediaContainer:"esri-feature-media__container",mediaItemContainer:"esri-feature-media__item-container",mediaItem:"esri-feature-media__item",mediaItemTitle:"esri-feature-media__item-title",mediaItemCaption:"esri-feature-media__item-caption",mediaPrevious:"esri-feature-media__previous",mediaPreviousIconLTR:"esri-feature-media__previous-icon",mediaPreviousIconRTL:"esri-feature-media__previous-icon--rtl",mediaNext:"esri-feature-media__next",mediaNextIconLTR:"esri-feature-media__next-icon",mediaNextIconRTL:"esri-feature-media__next-icon--rtl",mediaChart:"esri-feature-media__chart",mediaButton:"esri-feature-media__button",mediaIcon:"esri-feature-media__icon",iconLeftTriangleArrow:"esri-icon-left-triangle-arrow",iconRightTriangleArrow:"esri-icon-right-triangle-arrow"},_=.05,I=.95,M=15;let w=class extends s{constructor(e,t){super(e,t),this._refreshTimer=null,this._refreshIntervalInfo=null,this._featureElementInfo=null,this.attributes=null,this.activeMediaInfoIndex=null,this.description=null,this.fieldInfoMap=null,this.layer=null,this.mediaInfos=null,this.popupTemplate=null,this.relatedInfos=null,this.title=null,this.viewModel=new n,this.messages=null,this._getChartDependencies=async e=>{const t=await c(),{destroyed:i,viewModel:r}=this;if(i||!r||!e)return;const{activeMediaInfo:a}=r;this._renderChart({chartDiv:e,mediaInfo:a,chartsModule:t})}}initialize(){this._featureElementInfo=new l,this.own(i(this,["viewModel.activeMediaInfo","viewModel.activeMediaInfoIndex"],(()=>this._setupMediaRefreshTimer())),i(this,["viewModel.description","viewModel.title"],(()=>this._setupFeatureElementInfo())))}destroy(){this._clearMediaRefreshTimer(),this._featureElementInfo.destroy()}render(){var e;return p("div",{bind:this,class:v.base,onkeyup:this._handleMediaKeyup},null==(e=this._featureElementInfo)?void 0:e.render(),this.renderMedia())}renderMedia(){const{formattedMediaInfoCount:e}=this.viewModel;return e?p("div",{key:"media-element-container",class:v.mediaContainer},this.renderMediaPageButton("previous"),this.renderMediaInfo(),this.renderMediaPageButton("next")):null}renderImageMediaInfo(e){const{_refreshIntervalInfo:t}=this,{activeMediaInfoIndex:i,formattedMediaInfoCount:r}=this.viewModel,{value:a,refreshInterval:o,altText:s,title:n,type:l}=e,{sourceURL:c,linkURL:m}=a,u=d(m)?"_blank":"_self",h="_blank"===u?"noreferrer":"",f=o?t:null,v=f?f.timestamp:0,_=f?f.sourceURL:c,I=p("img",{alt:s||n,key:`media-${l}-${i}-${r}-${v}`,src:_}),M=m?p("a",{title:n,href:m,rel:h,target:u},I):null;return M||I}renderChartMediaInfo(e){const{activeMediaInfoIndex:t,formattedMediaInfoCount:i}=this.viewModel;return p("div",{key:`media-${e.type}-${t}-${i}`,bind:this,class:v.mediaChart,afterCreate:this._getChartDependencies})}renderMediaInfoType(){const{activeMediaInfo:e}=this.viewModel;return e?"image"===e.type?this.renderImageMediaInfo(e):-1!==e.type.indexOf("chart")?this.renderChartMediaInfo(e):null:null}renderMediaInfo(){const{activeMediaInfo:e}=this.viewModel;if(!e)return null;const t=e.title?p("div",{key:"media-title",class:v.mediaItemTitle,innerHTML:e.title}):null,i=e.caption?p("div",{key:"media-caption",class:v.mediaItemCaption,innerHTML:e.caption}):null;return p("div",{key:"media-container",class:v.mediaItemContainer},p("div",{key:"media-item-container",class:v.mediaItem},this.renderMediaInfoType()),t,i)}renderMediaPageButton(e){if(this.viewModel.formattedMediaInfoCount<2)return null;const t="previous"===e,i=t?this.messages.previous:this.messages.next,r=t?this.classes(v.mediaButton,v.mediaPrevious):this.classes(v.mediaButton,v.mediaNext),a=t?this.classes(v.mediaIcon,v.mediaPreviousIconLTR,v.iconLeftTriangleArrow):this.classes(v.mediaIcon,v.mediaNextIconLTR,v.iconRightTriangleArrow),o=t?this.classes(v.mediaIcon,v.mediaPreviousIconRTL,v.iconRightTriangleArrow):this.classes(v.mediaIcon,v.mediaNextIconRTL,v.iconLeftTriangleArrow),s=t?"media-previous":"media-next",n=t?this._previous:this._next;return p("button",{type:"button",key:s,title:i,"aria-label":i,tabIndex:0,class:r,bind:this,onclick:n},p("span",{"aria-hidden":"true",class:a}),p("span",{"aria-hidden":"true",class:o}))}_setupFeatureElementInfo(){const{description:e,title:t}=this;this._featureElementInfo.set({description:e,title:t})}_next(){this.viewModel.next()}_previous(){this.viewModel.previous()}_handleMediaKeyup(e){const i=t(e);"ArrowLeft"===i&&(e.stopPropagation(),this.viewModel.previous()),"ArrowRight"===i&&(e.stopPropagation(),this.viewModel.next())}_renderChart(e){const{abilities:t}=this.viewModel,{chartsModule:i,chartDiv:r,mediaInfo:a}=e,{value:o,type:s}=a,{am4core:n}=i,l=m(n);function d(e){e instanceof n.ColorSet&&l&&(e.list=l)}f()&&n.useTheme(i.am4themes_dark);const c=window.matchMedia("(prefers-reduced-motion: reduce)");t.chartAnimation&&!c.matches?n.useTheme(i.am4themes_animated):n.unuseTheme(i.am4themes_animated),n.useTheme(d);const u="pie-chart"===s?this._createPieChart(e):this._createXYChart(e);r.setAttribute("aria-label",a.altText||a.title),u.data=o.series.map((e=>({tooltip:e.tooltip,value:e.value}))).filter((e=>"pie-chart"!==s||e.value>0))}_customizeChartTooltip(e,t){e.label.wrap=!0,e.label.maxWidth=200,e.autoTextColor=!1,e.getFillFromObject=!1,e.label.fill=t.color("#ffffff"),e.background.fill=t.color({r:0,g:0,b:0,a:.7})}_createPieChart(e){const{chartDiv:t,chartsModule:i}=e,{am4core:r,am4charts:a}=i,o=r.create(t,a.PieChart);o.rtl=u(this.container);const s=o.series.push(new a.PieSeries);return s.labels.template.disabled=!0,s.ticks.template.disabled=!0,s.dataFields.value="value",s.dataFields.category="tooltip",this._customizeChartTooltip(s.tooltip,r),o}_getMinSeriesValue(e){let t=0;return e.forEach((e=>t=Math.min(e.value,t))),t}_createColumnChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.xAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dy=-n.tooltip.contentHeight}));const l=e.yAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.ColumnSeries);c.dataFields.valueY="value",c.dataFields.categoryX="tooltip",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarX=new o.Scrollbar)}_createBarChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.yAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.inversed=!0,n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dx=n.tooltip.contentWidth}));const l=e.xAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.ColumnSeries);c.dataFields.valueX="value",c.dataFields.categoryY="tooltip",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarY=new o.Scrollbar)}_createLineChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.xAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dy=-n.tooltip.contentHeight}));const l=e.yAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.LineSeries);c.dataFields.categoryX="tooltip",c.dataFields.valueY="value",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarX=new o.Scrollbar)}_createXYChart(e){const{chartDiv:t,chartsModule:i,mediaInfo:r}=e,{type:a}=r,{am4core:o,am4charts:s}=i,n=o.create(t,s.XYChart);return n.rtl=u(this.container),"column-chart"===a&&this._createColumnChart(n,e),"bar-chart"===a&&this._createBarChart(n,e),"line-chart"===a&&this._createLineChart(n,e),n}_clearMediaRefreshTimer(){const{_refreshTimer:e}=this;e&&(clearTimeout(e),this._refreshTimer=null)}_updateMediaInfoTimestamp(e){const t=Date.now();this._refreshIntervalInfo={timestamp:t,sourceURL:this._getImageSource(e,t)},this.scheduleRender()}_setupMediaRefreshTimer(){this._clearMediaRefreshTimer();const{activeMediaInfo:e}=this.viewModel;e&&"image"===e.type&&e.refreshInterval&&this._setRefreshTimeout(e)}_setRefreshTimeout(e){const{refreshInterval:t,value:i}=e;if(!t)return;const r=6e4*t;this._updateMediaInfoTimestamp(i.sourceURL);const a=setInterval((()=>{this._updateMediaInfoTimestamp(i.sourceURL)}),r);this._refreshTimer=a}_getImageSource(e,t){const i=-1!==e.indexOf("?")?"&":"?",[r,a=""]=e.split("#");return`${r}${i}timestamp=${t}${a?"#":""}${a}`}};e([r("viewModel.attributes")],w.prototype,"attributes",void 0),e([r("viewModel.activeMediaInfoIndex")],w.prototype,"activeMediaInfoIndex",void 0),e([r("viewModel.description")],w.prototype,"description",void 0),e([r("viewModel.fieldInfoMap")],w.prototype,"fieldInfoMap",void 0),e([r("viewModel.layer")],w.prototype,"layer",void 0),e([r("viewModel.mediaInfos")],w.prototype,"mediaInfos",void 0),e([r("viewModel.popupTemplate")],w.prototype,"popupTemplate",void 0),e([r("viewModel.relatedInfos")],w.prototype,"relatedInfos",void 0),e([r("viewModel.title")],w.prototype,"title",void 0),e([a({type:n})],w.prototype,"viewModel",void 0),e([a(),h("esri/widgets/Feature/t9n/Feature")],w.prototype,"messages",void 0),w=e([o("esri.widgets.Feature.FeatureMedia")],w);const g=w;export{g as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{eventKey as t}from"../../core/events.js";import{init as i}from"../../core/watchUtils.js";import{aliasOf as r}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import n from"./FeatureMedia/FeatureMediaViewModel.js";import l from"./support/FeatureElementInfo.js";import{shouldOpenInNewTab as d}from"./support/featureUtils.js";import{loadChartsModule as c,getColorSet as m}from"../support/chartUtils.js";import{isRTL as u}from"../support/widgetUtils.js";import{messageBundle as h}from"../support/decorators/messageBundle.js";import"../../core/Logger.js";import{tsx as p}from"../support/jsxFactory.js";import{isDarkTheme as f}from"../support/widgetThemeUtils.js";const v={base:"esri-feature-media",mediaContainer:"esri-feature-media__container",mediaItemContainer:"esri-feature-media__item-container",mediaItem:"esri-feature-media__item",mediaItemTitle:"esri-feature-media__item-title",mediaItemCaption:"esri-feature-media__item-caption",mediaPrevious:"esri-feature-media__previous",mediaPreviousIconLTR:"esri-feature-media__previous-icon",mediaPreviousIconRTL:"esri-feature-media__previous-icon--rtl",mediaNext:"esri-feature-media__next",mediaNextIconLTR:"esri-feature-media__next-icon",mediaNextIconRTL:"esri-feature-media__next-icon--rtl",mediaChart:"esri-feature-media__chart",mediaButton:"esri-feature-media__button",mediaIcon:"esri-feature-media__icon",iconLeftTriangleArrow:"esri-icon-left-triangle-arrow",iconRightTriangleArrow:"esri-icon-right-triangle-arrow"},_=.05,I=.95,M=15;let w=class extends s{constructor(e,t){super(e,t),this._refreshTimer=null,this._refreshIntervalInfo=null,this._featureElementInfo=null,this.attributes=null,this.activeMediaInfoIndex=null,this.description=null,this.fieldInfoMap=null,this.layer=null,this.mediaInfos=null,this.popupTemplate=null,this.relatedInfos=null,this.title=null,this.viewModel=new n,this.messages=null,this._getChartDependencies=async e=>{const t=await c(),{destroyed:i,viewModel:r}=this;if(i||!r||!e)return;const{activeMediaInfo:a}=r;this._renderChart({chartDiv:e,mediaInfo:a,chartsModule:t})}}initialize(){this._featureElementInfo=new l,this.own(i(this,["viewModel.activeMediaInfo","viewModel.activeMediaInfoIndex"],(()=>this._setupMediaRefreshTimer())),i(this,["viewModel.description","viewModel.title"],(()=>this._setupFeatureElementInfo())))}destroy(){this._clearMediaRefreshTimer(),this._featureElementInfo.destroy()}render(){var e;return p("div",{bind:this,class:v.base,onkeyup:this._handleMediaKeyup},null==(e=this._featureElementInfo)?void 0:e.render(),this.renderMedia())}renderMedia(){const{formattedMediaInfoCount:e}=this.viewModel;return e?p("div",{key:"media-element-container",class:v.mediaContainer},this.renderMediaPageButton("previous"),this.renderMediaInfo(),this.renderMediaPageButton("next")):null}renderImageMediaInfo(e){const{_refreshIntervalInfo:t}=this,{activeMediaInfoIndex:i,formattedMediaInfoCount:r}=this.viewModel,{value:a,refreshInterval:o,altText:s,title:n,type:l}=e,{sourceURL:c,linkURL:m}=a,u=d(m)?"_blank":"_self",h="_blank"===u?"noreferrer":"",f=o?t:null,v=f?f.timestamp:0,_=f?f.sourceURL:c,I=p("img",{alt:s||n,key:`media-${l}-${i}-${r}-${v}`,src:_}),M=m?p("a",{title:n,href:m,rel:h,target:u},I):null;return M||I}renderChartMediaInfo(e){const{activeMediaInfoIndex:t,formattedMediaInfoCount:i}=this.viewModel;return p("div",{key:`media-${e.type}-${t}-${i}`,bind:this,class:v.mediaChart,afterCreate:this._getChartDependencies})}renderMediaInfoType(){const{activeMediaInfo:e}=this.viewModel;return e?"image"===e.type?this.renderImageMediaInfo(e):-1!==e.type.indexOf("chart")?this.renderChartMediaInfo(e):null:null}renderMediaInfo(){const{activeMediaInfo:e}=this.viewModel;if(!e)return null;const t=e.title?p("div",{key:"media-title",class:v.mediaItemTitle,innerHTML:e.title}):null,i=e.caption?p("div",{key:"media-caption",class:v.mediaItemCaption,innerHTML:e.caption}):null;return p("div",{key:"media-container",class:v.mediaItemContainer},p("div",{key:"media-item-container",class:v.mediaItem},this.renderMediaInfoType()),t,i)}renderMediaPageButton(e){if(this.viewModel.formattedMediaInfoCount<2)return null;const t="previous"===e,i=t?this.messages.previous:this.messages.next,r=t?this.classes(v.mediaButton,v.mediaPrevious):this.classes(v.mediaButton,v.mediaNext),a=t?this.classes(v.mediaIcon,v.mediaPreviousIconLTR,v.iconLeftTriangleArrow):this.classes(v.mediaIcon,v.mediaNextIconLTR,v.iconRightTriangleArrow),o=t?this.classes(v.mediaIcon,v.mediaPreviousIconRTL,v.iconRightTriangleArrow):this.classes(v.mediaIcon,v.mediaNextIconRTL,v.iconLeftTriangleArrow),s=t?"media-previous":"media-next",n=t?this._previous:this._next;return p("button",{type:"button",key:s,title:i,"aria-label":i,tabIndex:0,class:r,bind:this,onclick:n},p("span",{"aria-hidden":"true",class:a}),p("span",{"aria-hidden":"true",class:o}))}_setupFeatureElementInfo(){const{description:e,title:t}=this;this._featureElementInfo.set({description:e,title:t})}_next(){this.viewModel.next()}_previous(){this.viewModel.previous()}_handleMediaKeyup(e){const i=t(e);"ArrowLeft"===i&&(e.stopPropagation(),this.viewModel.previous()),"ArrowRight"===i&&(e.stopPropagation(),this.viewModel.next())}_renderChart(e){const{abilities:t}=this.viewModel,{chartsModule:i,chartDiv:r,mediaInfo:a}=e,{value:o,type:s}=a,{am4core:n}=i,l=m(n);function d(e){e instanceof n.ColorSet&&l&&(e.list=l)}f()&&n.useTheme(i.am4themes_dark);const c=window.matchMedia("(prefers-reduced-motion: reduce)");t.chartAnimation&&!c.matches?n.useTheme(i.am4themes_animated):n.unuseTheme(i.am4themes_animated),n.useTheme(d);const u="pie-chart"===s?this._createPieChart(e):this._createXYChart(e);r.setAttribute("aria-label",a.altText||a.title),u.data=o.series.map((e=>({tooltip:e.tooltip,value:e.value}))).filter((e=>"pie-chart"!==s||e.value>0))}_customizeChartTooltip(e,t){e.label.wrap=!0,e.label.maxWidth=200,e.autoTextColor=!1,e.getFillFromObject=!1,e.label.fill=t.color("#ffffff"),e.background.fill=t.color({r:0,g:0,b:0,a:.7})}_createPieChart(e){const{chartDiv:t,chartsModule:i}=e,{am4core:r,am4charts:a}=i,o=r.create(t,a.PieChart);o.rtl=u(this.container);const s=o.series.push(new a.PieSeries);return s.labels.template.disabled=!0,s.ticks.template.disabled=!0,s.dataFields.value="value",s.dataFields.category="tooltip",this._customizeChartTooltip(s.tooltip,r),s.slices.template.tooltipText=o.rtl?"{category}: %{value.percent.formatNumber('#.0')}":"{category}: {value.percent.formatNumber('#.0')}%",o}_getMinSeriesValue(e){let t=0;return e.forEach((e=>t=Math.min(e.value,t))),t}_createColumnChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.xAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dy=-n.tooltip.contentHeight}));const l=e.yAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.ColumnSeries);c.dataFields.valueY="value",c.dataFields.categoryX="tooltip",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarX=new o.Scrollbar)}_createBarChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.yAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.inversed=!0,n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dx=n.tooltip.contentWidth}));const l=e.xAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.ColumnSeries);c.dataFields.valueX="value",c.dataFields.categoryY="tooltip",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarY=new o.Scrollbar)}_createLineChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.xAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dy=-n.tooltip.contentHeight}));const l=e.yAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.LineSeries);c.dataFields.categoryX="tooltip",c.dataFields.valueY="value",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarX=new o.Scrollbar)}_createXYChart(e){const{chartDiv:t,chartsModule:i,mediaInfo:r}=e,{type:a}=r,{am4core:o,am4charts:s}=i,n=o.create(t,s.XYChart);return n.rtl=u(this.container),"column-chart"===a&&this._createColumnChart(n,e),"bar-chart"===a&&this._createBarChart(n,e),"line-chart"===a&&this._createLineChart(n,e),n}_clearMediaRefreshTimer(){const{_refreshTimer:e}=this;e&&(clearTimeout(e),this._refreshTimer=null)}_updateMediaInfoTimestamp(e){const t=Date.now();this._refreshIntervalInfo={timestamp:t,sourceURL:this._getImageSource(e,t)},this.scheduleRender()}_setupMediaRefreshTimer(){this._clearMediaRefreshTimer();const{activeMediaInfo:e}=this.viewModel;e&&"image"===e.type&&e.refreshInterval&&this._setRefreshTimeout(e)}_setRefreshTimeout(e){const{refreshInterval:t,value:i}=e;if(!t)return;const r=6e4*t;this._updateMediaInfoTimestamp(i.sourceURL);const a=setInterval((()=>{this._updateMediaInfoTimestamp(i.sourceURL)}),r);this._refreshTimer=a}_getImageSource(e,t){const i=-1!==e.indexOf("?")?"&":"?",[r,a=""]=e.split("#");return`${r}${i}timestamp=${t}${a?"#":""}${a}`}};e([r("viewModel.attributes")],w.prototype,"attributes",void 0),e([r("viewModel.activeMediaInfoIndex")],w.prototype,"activeMediaInfoIndex",void 0),e([r("viewModel.description")],w.prototype,"description",void 0),e([r("viewModel.fieldInfoMap")],w.prototype,"fieldInfoMap",void 0),e([r("viewModel.layer")],w.prototype,"layer",void 0),e([r("viewModel.mediaInfos")],w.prototype,"mediaInfos",void 0),e([r("viewModel.popupTemplate")],w.prototype,"popupTemplate",void 0),e([r("viewModel.relatedInfos")],w.prototype,"relatedInfos",void 0),e([r("viewModel.title")],w.prototype,"title",void 0),e([a({type:n})],w.prototype,"viewModel",void 0),e([a(),h("esri/widgets/Feature/t9n/Feature")],w.prototype,"messages",void 0),w=e([o("esri.widgets.Feature.FeatureMedia")],w);const g=w;export{g 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.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import s from"../../core/Logger.js";import{destroyMaybe as o,isSome as l,isNone as r}from"../../core/maybe.js";import{EsriPromiseMixin as a}from"../../core/Promise.js";import{watch as u}from"../../core/reactiveUtils.js";import{ReentrantObjectPool as c}from"../../core/ReentrantObjectPool.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../form/FormTemplate.js";import f from"../../layers/support/ContingentValue.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{loadArcade as g}from"../../support/arcadeOnDemand.js";import y from"./InputField.js";import _ from"./InputFieldGroup.js";import{onLocaleChange as F}from"../../intl/locale.js";import{fetchMessageBundle as v}from"../../intl/messages.js";function C(e){return!!e.inputFields}const I=new t({attributes:{}}),E="esri.widgets.FeatureForm.FeatureFormViewModel",b=s.getLogger(E),V="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",j="#JSAPI_CONTINGENT_VALUE_ANY_HASH",A="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let w=class extends(n(a(i.EventedAccessor))){constructor(e){super(e),this._arcade=null,this._compiledExpressions=new Map,this._contingentValuesCache=null,this._fieldPool=new c(y),this._fieldGroupPool=new c(_),this._featureClone=I.clone(),this._initialFeature=I.clone(),this._needsArcade=!1,this._inputFieldCache=new Map,this._inputFieldGroupCache=new Map,this.contingencyConstraintViolations=new Map,this.messages=null,this.strict=!1}initialize(){const e=async()=>this.messages=await v("esri/widgets/FeatureForm/t9n/FeatureForm");e();const t=u((()=>this.layer),(e=>{"feature"===(null==e?void 0:e.type)&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(e).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0}),i=u((()=>{var e,t;const{formTemplate:i}=this;if(r(i))return null;const n=null!=(e=i.expressionInfos)?e:[],s=null!=(t=i.elements)?t:[];return[...n.map((e=>e.expression)),...null==s?void 0:s.map((e=>this._getExpressionsFromElementRecursive(e))).flat()]}),(async e=>{if(e.length<1)return;const t=new Set(e),n=new Map;if(l(this.formTemplate)&&l(this.formTemplate.expressionInfos))for(const i of this.formTemplate.expressionInfos)t.delete(i.name),n.set(i.expression,i.name);for(const i of this._compiledExpressions.keys())t.delete(i);if(t.size<1)return;this._needsArcade=!0;const s=await g();this._arcade=s;const{arcadeUtils:o}=s;for(const l of t.values()){var r;o.hasGeometryOperations(l)&&(await o.enableGeometryOperations(),i.remove()),this._setFunctionForExpression(null!=(r=n.get(l))?r:l,l)}this.notifyChange("inputFields")})),n=u((()=>this.formTemplate),(()=>this._compiledExpressions.clear()));this.handles.add([F(e),i,n,t])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this._fieldPool.destroy(),this._fieldGroupPool.destroy()}get allInputFields(){return this.inputFields.reduce(((e,t)=>C(t)?[...e,...t.inputFields]:[...e,t]),[])}get _layerFieldsByName(){return new Map(this.layer.fields.map((e=>[e.name,e])))}get description(){const{formTemplate:e}=this;return l(e)?e.description:""}set description(e){void 0===e?this._clearOverride("description"):this._override("description",e)}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():I.clone(),this._initialFeature=this._featureClone.clone(),this._inputFieldCache.clear(),this._inputFieldGroupCache.clear(),this._set("feature",e)}get fieldsWithContingentValues(){if(r(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 inputFields(){const{_arcade:e,_featureClone:t,_initialFeature:i,_inputFieldCache:n,_needsArcade:s,formTemplate:o,messages:r,layer:a,state:u}=this;if("ready"!==u||s&&!e)return[];const c=t.clone(),d=Array.from(n.keys()),p={arcade:e,feature:c,initialFeature:i,layer:a,messages:r},h=l(o)&&o.elements.length>0?this._generateInputFieldsFromElements(o.elements,p):this._generateInputFieldsFromLayerFields(null==a?void 0:a.fields,p);return this._cullInputFieldCache(this._flattenGroups(h).map((e=>e.name)),d),this._releasePreviousInputFields(),h.filter((e=>e.visible))}get joinedContingentValues(){return this._joinContingentValues()}get layer(){var e;return null!=(e=this.feature)&&e.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){e?this._override("layer",e):this._clearOverride("layer")}get state(){return this.messages&&this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allInputFields.filter((e=>!e.valid)).every((({submittable:e})=>e))}get title(){const{formTemplate:e}=this;return l(e)?e.title:""}set title(e){void 0===e?this._clearOverride("title"):this._override("title",e)}get valid(){const e=this.allInputFields;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allInputFields.find((t=>t.name===e))}getValue(e){var t;const{_featureClone:i,layer:n}=this,s=!(null==n||!n.getField(e));return null!=(t=i.getAttribute(e))?t:s?null:void 0}setValue(e,t){const{_featureClone:i,strict:n}=this,s=this.findField(e);if(t=""===t?null:t,!s||i.getAttribute(e)===t)return;s.value=t;if(this.get("layer.typeIdField")===s.name&&"types"in this.layer){const e=new Set;this.layer.types.forEach((t=>Object.keys(t.domains).forEach((t=>e.add(t))))),e.forEach((e=>{const t=this.findField(e);t&&t.notifyChange("domain")}))}n&&!s.valid||(i.setAttribute(e,t),this.notifyChange("inputFields"),this._emitChangeEvent(s))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allInputFields,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),i=e.filter((e=>!e.valid)).map((({name:e})=>e)),n=this.getValues();if(this.validateContingencyConstraints(n,{includeIncompleteViolations:!0}).length>0)for(const[s,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(s),i.push(s));this.emit("submit",{valid:[...t],invalid:i,values:n})}validateContingencyConstraints(e,t){const{_contingentValuesCache:i}=this,n=new Map;if(this.contingencyConstraintViolations=n,r(i))return[];const{invalid:s,incomplete:o}=i.validateContingencyConstraints(e),l=[...s,...null!=t&&t.includeIncompleteViolations?o:[]];for(const r of l)for(const e of r.fieldGroup.fields)n.set(e,r);return l}_cullInputFieldCache(e,t){const i=t.filter((t=>!e.includes(t)));for(const n in i)this._inputFieldCache.delete(n)}_flattenGroups(e){return e.flatMap((e=>"groupElement"in e?e.inputFields:e))}_releasePreviousInputFields(){const e=this._get("inputFields");if(e&&!(e.length<1))for(const t of e)"groupElement"in t?this._releaseInputFieldGroup(t):this._releaseInputField(t)}_releaseInputFieldGroup(e){e.inputFields.forEach((e=>this._releaseInputField(e))),this._fieldGroupPool.release(e)}_releaseInputField(e){this._fieldPool.release(e)}_emitChangeEvent({name:e,valid:t,value:i}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:i,valid:t})}_generateInputFieldsFromElements(e,t){const i=[];for(const n of e)this._isSupportedElement(n)&&i.push("group"===n.type?this._acquireAndInitializeInputFieldGroup(n,t):this._acquireAndInitializeInputField({field:this._layerFieldsByName.get(n.fieldName),fieldElement:n,...t}));return i}_generateInputFieldsFromLayerFields(e,t){return Array.isArray(e)?e.map((e=>this._acquireAndInitializeInputField({field:e,fieldElement:null,...t}))):(b.warn(E,"No attribute fields found."),[])}_acquireAndInitializeInputField(e){var t,i,n,s,o,l;const{arcade:r,feature:a,field:u,fieldElement:c,group:d,initialFeature:p,layer:h,messages:f}=e,m=null!=(t=this._compiledExpressions.get(null==c?void 0:c.requiredExpression))?t:void 0,g=null!=(i=this._compiledExpressions.get(null==c?void 0:c.visibilityExpression))?i:void 0,y=null!=(n=this._compiledExpressions.get(null==c?void 0:c.valueExpression))?n:void 0,_=null!=(s=this._compiledExpressions.get(null==c?void 0:c.editableExpression))?s:void 0,F=u.name,v=null!=(o=null==(l=this._inputFieldCache.get(F))?void 0:l.value)?o:this.getValue(F),C=this._fieldPool.acquire();return this._inputFieldCache.set(F,C),C.set({field:u,fieldElement:c,arcade:r,feature:a,group:d,initialFeature:p,layer:h,messages:f,requiredFunction:m,visibilityFunction:g,editableFunction:_,valueFunction:y,value:v})}_acquireAndInitializeInputFieldGroup(e,t){const i=this._fieldGroupPool.acquire(),n=[];for(const r of e.elements)this._isSupportedElement(r)&&n.push(this._acquireAndInitializeInputField({field:this._layerFieldsByName.get(r.fieldName),fieldElement:r,group:i,...t}));const{arcade:s,feature:o}=t,l=this._compiledExpressions.get(e.visibilityExpression);return i.set({arcade:s,feature:o,groupElement:e,inputFields:n,visibilityFunction:l})}_getExpressionsFromElementRecursive(e){const t=[];if(e.visibilityExpression&&t.push(e.visibilityExpression),"field"===e.type){const i=["requiredExpression","valueExpression","editableExpression"];for(const n of i)e[n]&&t.push(e[n])}if("group"===e.type&&e.elements)for(const i of e.elements)t.push(...this._getExpressionsFromElementRecursive(i));return t}_setFunctionForExpression(e,t){const{_arcade:{arcadeUtils:i},_compiledExpressions:n}=this;n.set(e,i.createFunction(t))}_isSupportedElement(e){return"field"===e.type||"group"===e.type||(b.warn("form-info::unsupported-element-type","Only element types 'field' and 'group' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}_joinContingentValues(){const e=this._contingentValuesCache;if(r(e))return[];const t="typeIdField"in this.layer?this.layer.typeIdField:null,i=t?this.getValue(t):null,n=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:s}=r,o=[];for(const n of e)n.isRetired||l(n.subtype)&&n.subtype.code!==i||o.push({values:n.values});o.length>0&&n.push({name:s,fields:t,contingencies:o})}const[s,o]=this._generateJoinPlan(n);return[...s.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,i=[],n=new Set;for(const a of e)for(const e of a.fields)if(t.has(e)){const s=t.get(e),o=a,l=[s.name,o.name].sort().join("|");if(n.has(l))continue;i.push([s,o]),n.add(l),t.set(e,o)}else t.set(e,a);const s=new Set(i.flat()),o=new Set(e);for(const a of s)o.delete(a);const l=new Map,r=new Map;for(const a of new Set(i.flat())){const e=Symbol(a.name);l.set(e,new Set([a])),r.set(a,e)}for(const[a,u]of i){const e=r.get(a),t=r.get(u);if(e===t)continue;const i=l.get(e),n=l.get(t);for(const s of n)i.add(s),r.set(s,e);l.delete(t)}return[[...l.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),i=t.shift();let n=t.shift(),s=this._generateJoinKey(i.fields,n.fields),o=new Set([...i.fields,...n.fields]),a=new Map;for(const l of i.contingencies){const[e]=this._hashContingency(l,s.codedValueFields,!0);a.has(e)?a.get(e).push(l):a.set(e,[l])}for(;t.length>0;){const e=new Map,i=t.shift(),l=this._generateJoinKey(o,i.fields);for(const t of n.contingencies){const[i,n]=this._hashContingency(t,s.codedValueFields),o=n?this._findMatchingContingenciesWithAnyHashMask(a,i):a.get(i);if(a.has(j)&&o.push(...this._findMatchingContingenciesContainingAny(t,a.get(j),s.codedValueFields)),!r(o))for(const a of o){const i=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(a,t,s.rangeFields):this._joinContingencies(a,t);if(r(i))break;const[n]=this._hashContingency(i,l.codedValueFields,!0);e.has(n)?e.get(n).push(i):e.set(n,[i])}}a=e,n=i,s=l,o=new Set([...o,...n.fields])}const u=[];for(const c of n.contingencies){const[e,t]=this._hashContingency(c,s.codedValueFields),i=t?this._findMatchingContingenciesWithAnyHashMask(a,e):a.get(e);if(a.has(j)&&i.push(...this._findMatchingContingenciesContainingAny(c,a.get(j),s.codedValueFields)),!r(i))for(const n of i){const e=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(n,c,s.rangeFields):this._joinContingencies(n,c);l(e)&&u.push(e)}}return u}_joinContingencies(e,t){const i={values:{...e.values,...t.values}};for(const[n,s]of Object.entries(i.values))"any"===s.objectType&&l(e.values[n])&&(i.values[n]=e.values[n]);return i}_joinContingenciesWithRangeDomains(e,t,i){const n=this._joinContingencies(e,t);for(const s of i){const i=e.values[s],o=t.values[s],{leftIsNull:l,rightIsNull:r,bothAreNull:a,leftIsAny:u,rightIsAny:c,bothAreAny:d,leftIsRange:p,rightIsRange:h}=this._compareObjectTypes(i.objectType,o.objectType);if(a||d)continue;if(l&&c||r&&u){n.values[s]=new f({objectType:"null"});continue}if(l&&h||r&&p)return null;u?(i.minValue=-1/0,i.maxValue=1/0):c&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(i.minValue,o.minValue),g=Math.min(i.maxValue,o.maxValue);if(m>g)return null;n.values[s]=new f({objectType:"range",minValue:m,maxValue:g})}return n}_findMatchingContingenciesContainingAny(e,t,i){return t.filter((t=>i.every((i=>{var n,s;const o=t.values[i],l=e.values[i];return"any"===o.objectType||"any"===l.objectType||(null==(n=o.codedValue)?void 0:n.code)===(null==(s=l.codedValue)?void 0:s.code)}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const i=RegExp(`${t}$`),n=[];for(const[s,o]of e){if(s===j)break;i.test(s)&&n.push(...o)}return n}_generateJoinKey(e,t){const i=Array.isArray(e)?new Set(e):e,n=Array.isArray(t)?new Set(t):t,s=i.size<n.size?i:n,o=s===i?n:i,l=new Set,a=new Set;for(const u of s)if(o.has(u)){const e=this.layer.getFieldDomain(u,{feature:this.feature});if(r(e))continue;switch(e.type){case"coded-value":l.add(u);break;case"range":a.add(u)}}return{codedValueFields:[...l],rangeFields:[...a]}}_hashContingency(e,t,i=!1){if(t.length<1)return[V,!1];const n=[];let s=!1;for(const l of t){const t=e.values[l];if("any"===t.objectType){if(i)return[j,!0];s=!0,n.push(`${l}:.*`)}else if("null"===t.objectType)n.push(`${l}:${A}`);else{var o;n.push(`${l}:${null==(o=t.codedValue)?void 0:o.code}`)}}return[n.sort().join("&"),s]}_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}}};e([d({readOnly:!0})],w.prototype,"allInputFields",null),e([d()],w.prototype,"_layerFieldsByName",null),e([d({readOnly:!0})],w.prototype,"_inputFieldCache",void 0),e([d({readOnly:!0})],w.prototype,"_inputFieldGroupCache",void 0),e([d()],w.prototype,"contingencyConstraintViolations",void 0),e([d()],w.prototype,"description",null),e([d()],w.prototype,"feature",null),e([d()],w.prototype,"fieldsWithContingentValues",null),e([d({type:h})],w.prototype,"formTemplate",null),e([d({readOnly:!0,dependsOn:["formTemplate","messages","feature","layer.fields","layer.loaded","state"]})],w.prototype,"inputFields",null),e([d()],w.prototype,"joinedContingentValues",null),e([d()],w.prototype,"layer",null),e([d()],w.prototype,"messages",void 0),e([d()],w.prototype,"state",null),e([d()],w.prototype,"strict",void 0),e([d()],w.prototype,"submittable",null),e([d()],w.prototype,"title",null),e([d()],w.prototype,"valid",null),e([d()],w.prototype,"getValues",null),e([d()],w.prototype,"submit",null),w=e([p(E)],w);const x=w;export{x as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import s from"../../core/Logger.js";import{destroyMaybe as o,isSome as l,isNone as r}from"../../core/maybe.js";import{EsriPromiseMixin as a}from"../../core/Promise.js";import{watch as u}from"../../core/reactiveUtils.js";import{ReentrantObjectPool as c}from"../../core/ReentrantObjectPool.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../form/FormTemplate.js";import f from"../../layers/support/ContingentValue.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{loadArcade as g}from"../../support/arcadeOnDemand.js";import y from"./InputField.js";import _ from"./InputFieldGroup.js";import{onLocaleChange as v}from"../../intl/locale.js";import{fetchMessageBundle as F}from"../../intl/messages.js";function C(e){return!!e.inputFields}const E=new t({attributes:{}}),I="esri.widgets.FeatureForm.FeatureFormViewModel",V=s.getLogger(I),b="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",j="#JSAPI_CONTINGENT_VALUE_ANY_HASH",A="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let w=class extends(n(a(i.EventedAccessor))){constructor(e){super(e),this._arcade=null,this._compiledExpressions=new Map,this._contingentValuesCache=null,this._fieldPool=new c(y,(e=>this.handles.add(u((()=>e.value),(()=>{e.isUsingValueExpression&&this._afterValueChange(e)})),e.id)),(({id:e})=>this.handles.remove(e))),this._fieldGroupPool=new c(_),this._featureClone=E.clone(),this._initialFeature=E.clone(),this._needsArcade=!1,this._inputFieldCache=new Map,this._inputFieldGroupCache=new Map,this.contingencyConstraintViolations=new Map,this.messages=null,this.strict=!1}initialize(){const e=async()=>this.messages=await F("esri/widgets/FeatureForm/t9n/FeatureForm");e();const t=u((()=>this.layer),(e=>{"feature"===(null==e?void 0:e.type)&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(e).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0}),i=u((()=>{var e,t;const{formTemplate:i}=this;if(r(i))return null;const n=null!=(e=i.expressionInfos)?e:[],s=null!=(t=i.elements)?t:[];return[...n.map((e=>e.expression)),...null==s?void 0:s.map((e=>this._getExpressionsFromElementRecursive(e))).flat()]}),(async e=>{if(e.length<1)return;const t=new Set(e),n=new Map;if(l(this.formTemplate)&&l(this.formTemplate.expressionInfos))for(const i of this.formTemplate.expressionInfos)t.delete(i.name),n.set(i.expression,i.name);for(const i of this._compiledExpressions.keys())t.delete(i);if(t.size<1)return;this._needsArcade=!0;const s=await g();this._arcade=s;const{arcadeUtils:o}=s;for(const l of t.values()){var r;o.hasGeometryOperations(l)&&(await o.enableGeometryOperations(),i.remove()),this._setFunctionForExpression(null!=(r=n.get(l))?r:l,l)}this.notifyChange("inputFields")})),n=u((()=>this.formTemplate),(()=>this._compiledExpressions.clear()));this.handles.add([v(e),i,n,t])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this._fieldPool.destroy(),this._fieldGroupPool.destroy()}get allInputFields(){return this.inputFields.reduce(((e,t)=>C(t)?[...e,...t.inputFields]:[...e,t]),[])}get _layerFieldsByName(){return new Map(this.layer.fields.map((e=>[e.name,e])))}get description(){const{formTemplate:e}=this;return l(e)?e.description:""}set description(e){void 0===e?this._clearOverride("description"):this._override("description",e)}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():E.clone(),this._initialFeature=this._featureClone.clone(),this._inputFieldCache.clear(),this._inputFieldGroupCache.clear(),this._set("feature",e)}get fieldsWithContingentValues(){if(r(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 inputFields(){const{_arcade:e,_featureClone:t,_initialFeature:i,_inputFieldCache:n,_needsArcade:s,formTemplate:o,messages:r,layer:a,state:u}=this;if("ready"!==u||s&&!e)return[];const c=t.clone(),d=Array.from(n.keys()),p={arcade:e,feature:c,initialFeature:i,layer:a,messages:r},h=l(o)&&o.elements.length>0?this._generateInputFieldsFromElements(o.elements,p):this._generateInputFieldsFromLayerFields(null==a?void 0:a.fields,p);return this._cullInputFieldCache(this._flattenGroups(h).map((e=>e.name)),d),this._releasePreviousInputFields(),h.filter((e=>e.visible))}get joinedContingentValues(){return this._joinContingentValues()}get layer(){var e;return null!=(e=this.feature)&&e.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){e?this._override("layer",e):this._clearOverride("layer")}get state(){return this.messages&&this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allInputFields.filter((e=>!e.valid)).every((({submittable:e})=>e))}get title(){const{formTemplate:e}=this;return l(e)?e.title:""}set title(e){void 0===e?this._clearOverride("title"):this._override("title",e)}get valid(){const e=this.allInputFields;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allInputFields.find((t=>t.name===e))}getValue(e){var t;const{_featureClone:i,layer:n}=this,s=!(null==n||!n.getField(e));return null!=(t=i.getAttribute(e))?t:s?null:void 0}setValue(e,t){const{_featureClone:i,strict:n}=this,s=this.findField(e);t=""===t?null:t,s&&i.getAttribute(e)!==t&&(s.value=t,n&&!s.valid||this._afterValueChange(s))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allInputFields,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),i=e.filter((e=>!e.valid)).map((({name:e})=>e)),n=this.getValues();if(this.validateContingencyConstraints(n,{includeIncompleteViolations:!0}).length>0)for(const[s,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(s),i.push(s));this.emit("submit",{valid:[...t],invalid:i,values:n})}validateContingencyConstraints(e,t){const{_contingentValuesCache:i}=this,n=new Map;if(this.contingencyConstraintViolations=n,r(i))return[];const{invalid:s,incomplete:o}=i.validateContingencyConstraints(e),l=[...s,...null!=t&&t.includeIncompleteViolations?o:[]];for(const r of l)for(const e of r.fieldGroup.fields)n.set(e,r);return l}_cullInputFieldCache(e,t){const i=t.filter((t=>!e.includes(t)));for(const n in i)this._inputFieldCache.delete(n)}_flattenGroups(e){return e.flatMap((e=>"groupElement"in e?e.inputFields:e))}_releasePreviousInputFields(){const e=this._get("inputFields");if(e&&!(e.length<1))for(const t of e)"groupElement"in t?this._releaseInputFieldGroup(t):this._releaseInputField(t)}_releaseInputFieldGroup(e){e.inputFields.forEach((e=>this._releaseInputField(e))),this._fieldGroupPool.release(e)}_releaseInputField(e){this._fieldPool.release(e)}_emitChangeEvent({name:e,valid:t,value:i}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:i,valid:t})}_generateInputFieldsFromElements(e,t){const i=[];for(const n of e)this._isSupportedElement(n)&&i.push("group"===n.type?this._acquireAndInitializeInputFieldGroup(n,t):this._acquireAndInitializeInputField({field:this._layerFieldsByName.get(n.fieldName),fieldElement:n,...t}));return i}_generateInputFieldsFromLayerFields(e,t){return Array.isArray(e)?e.map((e=>this._acquireAndInitializeInputField({field:e,fieldElement:null,...t}))):(V.warn(I,"No attribute fields found."),[])}_acquireAndInitializeInputField(e){var t,i,n,s,o,l;const{arcade:r,feature:a,field:u,fieldElement:c,group:d,initialFeature:p,layer:h,messages:f}=e,m=null!=(t=this._compiledExpressions.get(null==c?void 0:c.requiredExpression))?t:void 0,g=null!=(i=this._compiledExpressions.get(null==c?void 0:c.visibilityExpression))?i:void 0,y=null!=(n=this._compiledExpressions.get(null==c?void 0:c.valueExpression))?n:void 0,_=null!=(s=this._compiledExpressions.get(null==c?void 0:c.editableExpression))?s:void 0,v=u.name,F=null!=(o=null==(l=this._inputFieldCache.get(v))?void 0:l.value)?o:this.getValue(v),C=this._fieldPool.acquire();return this._inputFieldCache.set(v,C),C.set({field:u,fieldElement:c,arcade:r,feature:a,group:d,initialFeature:p,layer:h,messages:f,requiredFunction:m,visibilityFunction:g,editableFunction:_,valueFunction:y,value:F})}_acquireAndInitializeInputFieldGroup(e,t){const i=this._fieldGroupPool.acquire(),n=[];for(const r of e.elements)this._isSupportedElement(r)&&n.push(this._acquireAndInitializeInputField({field:this._layerFieldsByName.get(r.fieldName),fieldElement:r,group:i,...t}));const{arcade:s,feature:o}=t,l=this._compiledExpressions.get(e.visibilityExpression);return i.set({arcade:s,feature:o,groupElement:e,inputFields:n,visibilityFunction:l})}_afterValueChange(e){const{name:t,value:i}=e;if(this.get("layer.typeIdField")===e.name&&"types"in this.layer){const e=new Set;this.layer.types.forEach((t=>Object.keys(t.domains).forEach((t=>e.add(t))))),e.forEach((e=>{const t=this.findField(e);t&&t.notifyChange("domain")}))}this._featureClone.setAttribute(t,i),this.notifyChange("inputFields"),this._emitChangeEvent(e)}_getExpressionsFromElementRecursive(e){const t=[];if(e.visibilityExpression&&t.push(e.visibilityExpression),"field"===e.type){const i=["requiredExpression","valueExpression","editableExpression"];for(const n of i)e[n]&&t.push(e[n])}if("group"===e.type&&e.elements)for(const i of e.elements)t.push(...this._getExpressionsFromElementRecursive(i));return t}_setFunctionForExpression(e,t){const{_arcade:{arcadeUtils:i},_compiledExpressions:n}=this;n.set(e,i.createFunction(t))}_isSupportedElement(e){return"field"===e.type||"group"===e.type||(V.warn("form-info::unsupported-element-type","Only element types 'field' and 'group' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}_joinContingentValues(){const e=this._contingentValuesCache;if(r(e))return[];const t="typeIdField"in this.layer?this.layer.typeIdField:null,i=t?this.getValue(t):null,n=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:s}=r,o=[];for(const n of e)n.isRetired||l(n.subtype)&&n.subtype.code!==i||o.push({values:n.values});o.length>0&&n.push({name:s,fields:t,contingencies:o})}const[s,o]=this._generateJoinPlan(n);return[...s.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,i=[],n=new Set;for(const a of e)for(const e of a.fields)if(t.has(e)){const s=t.get(e),o=a,l=[s.name,o.name].sort().join("|");if(n.has(l))continue;i.push([s,o]),n.add(l),t.set(e,o)}else t.set(e,a);const s=new Set(i.flat()),o=new Set(e);for(const a of s)o.delete(a);const l=new Map,r=new Map;for(const a of new Set(i.flat())){const e=Symbol(a.name);l.set(e,new Set([a])),r.set(a,e)}for(const[a,u]of i){const e=r.get(a),t=r.get(u);if(e===t)continue;const i=l.get(e),n=l.get(t);for(const s of n)i.add(s),r.set(s,e);l.delete(t)}return[[...l.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),i=t.shift();let n=t.shift(),s=this._generateJoinKey(i.fields,n.fields),o=new Set([...i.fields,...n.fields]),a=new Map;for(const l of i.contingencies){const[e]=this._hashContingency(l,s.codedValueFields,!0);a.has(e)?a.get(e).push(l):a.set(e,[l])}for(;t.length>0;){const e=new Map,i=t.shift(),l=this._generateJoinKey(o,i.fields);for(const t of n.contingencies){const[i,n]=this._hashContingency(t,s.codedValueFields),o=n?this._findMatchingContingenciesWithAnyHashMask(a,i):a.get(i);if(a.has(j)&&o.push(...this._findMatchingContingenciesContainingAny(t,a.get(j),s.codedValueFields)),!r(o))for(const a of o){const i=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(a,t,s.rangeFields):this._joinContingencies(a,t);if(r(i))break;const[n]=this._hashContingency(i,l.codedValueFields,!0);e.has(n)?e.get(n).push(i):e.set(n,[i])}}a=e,n=i,s=l,o=new Set([...o,...n.fields])}const u=[];for(const c of n.contingencies){const[e,t]=this._hashContingency(c,s.codedValueFields),i=t?this._findMatchingContingenciesWithAnyHashMask(a,e):a.get(e);if(a.has(j)&&i.push(...this._findMatchingContingenciesContainingAny(c,a.get(j),s.codedValueFields)),!r(i))for(const n of i){const e=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(n,c,s.rangeFields):this._joinContingencies(n,c);l(e)&&u.push(e)}}return u}_joinContingencies(e,t){const i={values:{...e.values,...t.values}};for(const[n,s]of Object.entries(i.values))"any"===s.objectType&&l(e.values[n])&&(i.values[n]=e.values[n]);return i}_joinContingenciesWithRangeDomains(e,t,i){const n=this._joinContingencies(e,t);for(const s of i){const i=e.values[s],o=t.values[s],{leftIsNull:l,rightIsNull:r,bothAreNull:a,leftIsAny:u,rightIsAny:c,bothAreAny:d,leftIsRange:p,rightIsRange:h}=this._compareObjectTypes(i.objectType,o.objectType);if(a||d)continue;if(l&&c||r&&u){n.values[s]=new f({objectType:"null"});continue}if(l&&h||r&&p)return null;u?(i.minValue=-1/0,i.maxValue=1/0):c&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(i.minValue,o.minValue),g=Math.min(i.maxValue,o.maxValue);if(m>g)return null;n.values[s]=new f({objectType:"range",minValue:m,maxValue:g})}return n}_findMatchingContingenciesContainingAny(e,t,i){return t.filter((t=>i.every((i=>{var n,s;const o=t.values[i],l=e.values[i];return"any"===o.objectType||"any"===l.objectType||(null==(n=o.codedValue)?void 0:n.code)===(null==(s=l.codedValue)?void 0:s.code)}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const i=RegExp(`${t}$`),n=[];for(const[s,o]of e){if(s===j)break;i.test(s)&&n.push(...o)}return n}_generateJoinKey(e,t){const i=Array.isArray(e)?new Set(e):e,n=Array.isArray(t)?new Set(t):t,s=i.size<n.size?i:n,o=s===i?n:i,l=new Set,a=new Set;for(const u of s)if(o.has(u)){const e=this.layer.getFieldDomain(u,{feature:this.feature});if(r(e))continue;switch(e.type){case"coded-value":l.add(u);break;case"range":a.add(u)}}return{codedValueFields:[...l],rangeFields:[...a]}}_hashContingency(e,t,i=!1){if(t.length<1)return[b,!1];const n=[];let s=!1;for(const l of t){const t=e.values[l];if("any"===t.objectType){if(i)return[j,!0];s=!0,n.push(`${l}:.*`)}else if("null"===t.objectType)n.push(`${l}:${A}`);else{var o;n.push(`${l}:${null==(o=t.codedValue)?void 0:o.code}`)}}return[n.sort().join("&"),s]}_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}}};e([d({readOnly:!0})],w.prototype,"allInputFields",null),e([d()],w.prototype,"_layerFieldsByName",null),e([d({readOnly:!0})],w.prototype,"_inputFieldCache",void 0),e([d({readOnly:!0})],w.prototype,"_inputFieldGroupCache",void 0),e([d()],w.prototype,"contingencyConstraintViolations",void 0),e([d()],w.prototype,"description",null),e([d()],w.prototype,"feature",null),e([d()],w.prototype,"fieldsWithContingentValues",null),e([d({type:h})],w.prototype,"formTemplate",null),e([d({readOnly:!0,dependsOn:["formTemplate","messages","feature","layer.fields","layer.loaded","state"]})],w.prototype,"inputFields",null),e([d()],w.prototype,"joinedContingentValues",null),e([d()],w.prototype,"layer",null),e([d()],w.prototype,"messages",void 0),e([d()],w.prototype,"state",null),e([d()],w.prototype,"strict",void 0),e([d()],w.prototype,"submittable",null),e([d()],w.prototype,"title",null),e([d()],w.prototype,"valid",null),e([d()],w.prototype,"getValues",null),e([d()],w.prototype,"submit",null),w=e([p(I)],w);const x=w;export{x 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.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{isSome as l,isNone as r,get as n}from"../../core/maybe.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import u from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{validateDomainValue as d,DomainValidationError as p,getDomainRange as c}from"../../layers/support/domainUtils.js";import{isNumericField as h,isStringField as m,isDateField as y,TypeValidationError as v,validateFieldValue as f,getFeatureEditFields as g,getFeatureGeometryFields as E,NumericRangeValidationError as b,getFieldRange as _}from"../../layers/support/fieldUtils.js";import{substitute as x}from"../../intl/substitute.js";var F,V;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(F||(F={})),function(e){e.TOO_SHORT="length-validation-error::too-short"}(V||(V={}));const O={type:"number"},U={type:"number",intlOptions:{notation:"scientific"}},T={type:"date",intlOptions:{day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}};let A=class extends(i(t)){constructor(e){super(e),this._storedValue=null,this.arcade=null,this.editableFunction=null,this.requiredFunction=null,this.valueFunction=null,this.visibilityFunction=null,this.feature=null,this.field=null,this.fieldElement=null,this.layer=null,this.description=null,this.inputType=null,this.error=null,this.group=null,this.hint=null,this.messages=null,this.name=null}initialize(){this.handles.add(o((()=>this.value),((e,t)=>{if(e!==t){const{feature:e,name:t,value:i}=this;e.setAttribute(t,i)}})))}get _configAllowsEdits(){var e,t,i;const{fieldElement:r,layer:n,name:o}=this;if(l(r))return!1!==r.editable;const s="subtype-group"!==(null==n?void 0:n.type)?null==n||null==(e=n.popupTemplate)||null==(t=e.fieldInfos)?void 0:t.find((({fieldName:e})=>e===o)):null;return null==(i=null==s?void 0:s.isEditable)||i}get _layerFieldAllowsEdits(){const{field:e,layer:t}=this;return(null==t?void 0:t.capabilities.operations.supportsEditing)&&(null==e?void 0:e.editable)}get isUsingValueExpression(){return this._shouldUseValueExpression()}get evaluatedEditableExpression(){const{editableFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedRequiredExpression(){const{requiredFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedVisibilityExpression(){const{visibilityFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedValueExpression(){const{valueFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get domain(){var e;const{typeIdField:t}=this.layer,i=t===this.name,r=null==(e=this.field)?void 0:e.domain;if(i&&!r){const{layer:e}=this,t="subtype-group"===e.type?e.sublayers.map((({subtypeCode:e,title:t})=>({id:e,name:t}))):e.types.map((({id:e,name:t})=>({code:e,name:t})));return new u({name:"__internal-type-based-coded-value-domain__",codedValues:t})}const{feature:o}=this,s=t&&this.layer.getFieldDomain(this.name,{feature:o})||r,a=n(this.fieldElement,"domain");return l(a)&&this._isDomainCompatible(a)?a:s}get editable(){var e;return!!this._layerFieldAllowsEdits&&(null!=(e=this.evaluatedEditableExpression)?e:this._configAllowsEdits)}get errorMessage(){return this._toErrorMessage()}get includeTime(){var e;const{fieldElement:t}=this,i=l(t)&&"datetime-picker"===(null==(e=t.input)?void 0:e.type)?t.input.includeTime:void 0;return void 0===i||i}get label(){return l(this.fieldElement)&&this.fieldElement.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.type===F.Date)return e;const{field:t,fieldElement:i}=this,r=null==t?void 0:t.length,n=l(i)&&j(i.input)?i.input.maxLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:r}get minLength(){const e=-1;if(this.type===F.Date)return e;const{field:t,fieldElement:i}=this,r=null==t?void 0:t.length,n=l(i)&&j(i.input)?i.input.minLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:e}get required(){var e,t;return!!this.editable&&(!1===(null==(e=this.field)?void 0:e.nullable)||null!=(t=this.evaluatedRequiredExpression)&&t)}get submittable(){return!!this.valid||this.initialFeature.getAttribute(this.field.name)===this.value}get type(){const{field:e}=this;return h(e)?F.Number:m(e)?F.Text:y(e)?F.Date:F.Unsupported}get valid(){const e=this._validate();return this._set("error",e),null===e}get value(){return this._shouldUseValueExpression()?this.evaluatedValueExpression:this.get("_storedValue")}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditorField()&&(l(this.fieldElement)?null==(e=this.evaluatedVisibilityExpression)||e:this._isVisibleByDefault());var e}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===(null==e?void 0:e.type)){const i=typeof e.codedValues[0].code;if("string"===i&&m(t)||"number"===i&&h(t))return!0}return!!("range"===(null==e?void 0:e.type)&&h(t)||y(t))}_validate(){const{domain:e,field:t,initialFeature:i,minLength:l,required:r,type:n,valid:o,value:s}=this,a=r&&null===s,u=void 0!==o;return!a&&i.getAttribute(t.name)===s&&u?null:"text"===n&&l>-1&&"string"==typeof s&&s.length<l?V.TOO_SHORT:e?null!==s||r?d(e,s):null:a?v.INVALID_TYPE:f(t,s)}_isVisibleByDefault(){var e;const t=null==(e=this.field)?void 0:e.type;return"oid"!==t&&"global-id"!==t&&!this._isGeometryField()}_isEditorField(){return g(this.layer).indexOf(this.name)>-1}_isGeometryField(){return E(this.layer).indexOf(this.name)>-1}_shouldUseValueExpression(){return this._layerFieldAllowsEdits&&!this._configAllowsEdits&&l(this.valueFunction)}_toErrorMessage(){const{domain:e,field:t,messages:i,minLength:l,value:r,required:n,type:o}=this,s=this.error;if(n&&null===r)return i.validationErrors.cannotBeNull;if(s===p.VALUE_OUT_OF_RANGE||s===b.OUT_OF_RANGE){const l=c(e)||_(t);return x(i.validationErrors.outsideRange,l,{format:{max:"date"===o?T:l.isInteger?O:U,min:"date"===o?T:l.isInteger?O:U}})}return s===p.INVALID_CODED_VALUE?i.validationErrors.invalidCodedValue:s===v.INVALID_TYPE?i.validationErrors.invalidType:s===V.TOO_SHORT?x(i.validationErrors.tooShort,{min:l}):null}};function j(e){return!!e&&"maxLength"in e}e([s()],A.prototype,"_storedValue",void 0),e([s()],A.prototype,"_configAllowsEdits",null),e([s()],A.prototype,"_layerFieldAllowsEdits",null),e([s()],A.prototype,"arcade",void 0),e([s()],A.prototype,"editableFunction",void 0),e([s()],A.prototype,"requiredFunction",void 0),e([s()],A.prototype,"valueFunction",void 0),e([s()],A.prototype,"isUsingValueExpression",null),e([s()],A.prototype,"visibilityFunction",void 0),e([s()],A.prototype,"evaluatedEditableExpression",null),e([s()],A.prototype,"evaluatedRequiredExpression",null),e([s()],A.prototype,"evaluatedVisibilityExpression",null),e([s()],A.prototype,"evaluatedValueExpression",null),e([s()],A.prototype,"feature",void 0),e([s()],A.prototype,"field",void 0),e([s()],A.prototype,"fieldElement",void 0),e([s()],A.prototype,"initialFeature",null),e([s()],A.prototype,"layer",void 0),e([s({aliasOf:"fieldElement.description"})],A.prototype,"description",void 0),e([s()],A.prototype,"domain",null),e([s()],A.prototype,"editable",null),e([s({aliasOf:"fieldElement.input.type"})],A.prototype,"inputType",void 0),e([s({readOnly:!0})],A.prototype,"error",void 0),e([s({dependsOn:["error","messages","value"]})],A.prototype,"errorMessage",null),e([s()],A.prototype,"group",void 0),e([s({aliasOf:"fieldElement.hint"})],A.prototype,"hint",void 0),e([s()],A.prototype,"includeTime",null),e([s()],A.prototype,"label",null),e([s()],A.prototype,"maxLength",null),e([s()],A.prototype,"minLength",null),e([s()],A.prototype,"messages",void 0),e([s({aliasOf:"field.name"})],A.prototype,"name",void 0),e([s()],A.prototype,"required",null),e([s()],A.prototype,"submittable",null),e([s()],A.prototype,"type",null),e([s()],A.prototype,"valid",null),e([s({value:null})],A.prototype,"value",null),e([s()],A.prototype,"visible",null),A=e([a("esri.widgets.FeatureForm.InputField")],A);const D=A;export{D as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{isSome as l,isNone as r,get as n}from"../../core/maybe.js";import{watch as o}from"../../core/reactiveUtils.js";import{generateUID as s}from"../../core/uid.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{validateDomainValue as p,DomainValidationError as c,getDomainRange as h}from"../../layers/support/domainUtils.js";import{isNumericField as m,isStringField as y,isDateField as v,TypeValidationError as f,validateFieldValue as g,getFeatureEditFields as E,getFeatureGeometryFields as b,NumericRangeValidationError as _,getFieldRange as x}from"../../layers/support/fieldUtils.js";import{substitute as F}from"../../intl/substitute.js";var V,O;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(V||(V={})),function(e){e.TOO_SHORT="length-validation-error::too-short"}(O||(O={}));const U={type:"number"},T={type:"number",intlOptions:{notation:"scientific"}},j={type:"date",intlOptions:{day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}};let A=class extends(i(t)){constructor(e){super(e),this._storedValue=null,this.arcade=null,this.editableFunction=null,this.id=s().toString(),this.requiredFunction=null,this.valueFunction=null,this.visibilityFunction=null,this.feature=null,this.field=null,this.fieldElement=null,this.layer=null,this.description=null,this.inputType=null,this.error=null,this.group=null,this.hint=null,this.messages=null,this.name=null}initialize(){this.handles.add(o((()=>this.value),((e,t)=>{if(e!==t){const{feature:e,name:t,value:i}=this;e.setAttribute(t,i)}})))}get _configAllowsEdits(){var e,t,i;const{fieldElement:r,layer:n,name:o}=this;if(l(r))return!1!==r.editable;const s="subtype-group"!==(null==n?void 0:n.type)?null==n||null==(e=n.popupTemplate)||null==(t=e.fieldInfos)?void 0:t.find((({fieldName:e})=>e===o)):null;return null==(i=null==s?void 0:s.isEditable)||i}get _layerFieldAllowsEdits(){const{field:e,layer:t}=this;return(null==t?void 0:t.capabilities.operations.supportsEditing)&&(null==e?void 0:e.editable)}get isUsingValueExpression(){return this._shouldUseValueExpression()}get evaluatedEditableExpression(){const{editableFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedRequiredExpression(){const{requiredFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedVisibilityExpression(){const{visibilityFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedValueExpression(){const{valueFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get domain(){var e;const{typeIdField:t}=this.layer,i=t===this.name,r=null==(e=this.field)?void 0:e.domain;if(i&&!r){const{layer:e}=this,t="subtype-group"===e.type?e.sublayers.map((({subtypeCode:e,title:t})=>({id:e,name:t}))):e.types.map((({id:e,name:t})=>({code:e,name:t})));return new d({name:"__internal-type-based-coded-value-domain__",codedValues:t})}const{feature:o}=this,s=t&&this.layer.getFieldDomain(this.name,{feature:o})||r,a=n(this.fieldElement,"domain");return l(a)&&this._isDomainCompatible(a)?a:s}get editable(){var e;return!!this._layerFieldAllowsEdits&&(null!=(e=this.evaluatedEditableExpression)?e:this._configAllowsEdits)}get errorMessage(){return this._toErrorMessage()}get includeTime(){var e;const{fieldElement:t}=this,i=l(t)&&"datetime-picker"===(null==(e=t.input)?void 0:e.type)?t.input.includeTime:void 0;return void 0===i||i}get label(){return l(this.fieldElement)&&this.fieldElement.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.type===V.Date)return e;const{field:t,fieldElement:i}=this,r=null==t?void 0:t.length,n=l(i)&&D(i.input)?i.input.maxLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:r}get minLength(){const e=-1;if(this.type===V.Date)return e;const{field:t,fieldElement:i}=this,r=null==t?void 0:t.length,n=l(i)&&D(i.input)?i.input.minLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:e}get required(){var e,t;return!!this.editable&&(!1===(null==(e=this.field)?void 0:e.nullable)||null!=(t=this.evaluatedRequiredExpression)&&t)}get submittable(){return!!this.valid||this.initialFeature.getAttribute(this.field.name)===this.value}get type(){const{field:e}=this;return m(e)?V.Number:y(e)?V.Text:v(e)?V.Date:V.Unsupported}get valid(){const e=this._validate();return this._set("error",e),null===e}get value(){return this._shouldUseValueExpression()?this.evaluatedValueExpression:this.get("_storedValue")}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditorField()&&(l(this.fieldElement)?null==(e=this.evaluatedVisibilityExpression)||e:this._isVisibleByDefault());var e}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===(null==e?void 0:e.type)){const i=typeof e.codedValues[0].code;if("string"===i&&y(t)||"number"===i&&m(t))return!0}return!!("range"===(null==e?void 0:e.type)&&m(t)||v(t))}_validate(){const{domain:e,field:t,initialFeature:i,minLength:l,required:r,type:n,valid:o,value:s}=this,a=r&&null===s,u=void 0!==o;return!a&&i.getAttribute(t.name)===s&&u?null:"text"===n&&l>-1&&"string"==typeof s&&s.length<l?O.TOO_SHORT:e?null!==s||r?p(e,s):null:a?f.INVALID_TYPE:g(t,s)}_isVisibleByDefault(){var e;const t=null==(e=this.field)?void 0:e.type;return"oid"!==t&&"global-id"!==t&&!this._isGeometryField()}_isEditorField(){return E(this.layer).indexOf(this.name)>-1}_isGeometryField(){return b(this.layer).indexOf(this.name)>-1}_shouldUseValueExpression(){return this._layerFieldAllowsEdits&&!this._configAllowsEdits&&l(this.valueFunction)}_toErrorMessage(){const{domain:e,field:t,messages:i,minLength:l,value:r,required:n,type:o}=this,s=this.error;if(n&&null===r)return i.validationErrors.cannotBeNull;if(s===c.VALUE_OUT_OF_RANGE||s===_.OUT_OF_RANGE){const l=h(e)||x(t);return F(i.validationErrors.outsideRange,l,{format:{max:"date"===o?j:l.isInteger?U:T,min:"date"===o?j:l.isInteger?U:T}})}return s===c.INVALID_CODED_VALUE?i.validationErrors.invalidCodedValue:s===f.INVALID_TYPE?i.validationErrors.invalidType:s===O.TOO_SHORT?F(i.validationErrors.tooShort,{min:l}):null}};function D(e){return!!e&&"maxLength"in e}e([a()],A.prototype,"_storedValue",void 0),e([a()],A.prototype,"_configAllowsEdits",null),e([a()],A.prototype,"_layerFieldAllowsEdits",null),e([a()],A.prototype,"arcade",void 0),e([a()],A.prototype,"editableFunction",void 0),e([a()],A.prototype,"requiredFunction",void 0),e([a()],A.prototype,"valueFunction",void 0),e([a()],A.prototype,"isUsingValueExpression",null),e([a()],A.prototype,"visibilityFunction",void 0),e([a()],A.prototype,"evaluatedEditableExpression",null),e([a()],A.prototype,"evaluatedRequiredExpression",null),e([a()],A.prototype,"evaluatedVisibilityExpression",null),e([a()],A.prototype,"evaluatedValueExpression",null),e([a()],A.prototype,"feature",void 0),e([a()],A.prototype,"field",void 0),e([a()],A.prototype,"fieldElement",void 0),e([a()],A.prototype,"initialFeature",null),e([a()],A.prototype,"layer",void 0),e([a({aliasOf:"fieldElement.description"})],A.prototype,"description",void 0),e([a()],A.prototype,"domain",null),e([a()],A.prototype,"editable",null),e([a({aliasOf:"fieldElement.input.type"})],A.prototype,"inputType",void 0),e([a({readOnly:!0})],A.prototype,"error",void 0),e([a({dependsOn:["error","messages","value"]})],A.prototype,"errorMessage",null),e([a()],A.prototype,"group",void 0),e([a({aliasOf:"fieldElement.hint"})],A.prototype,"hint",void 0),e([a()],A.prototype,"includeTime",null),e([a()],A.prototype,"label",null),e([a()],A.prototype,"maxLength",null),e([a()],A.prototype,"minLength",null),e([a()],A.prototype,"messages",void 0),e([a({aliasOf:"field.name"})],A.prototype,"name",void 0),e([a()],A.prototype,"required",null),e([a()],A.prototype,"submittable",null),e([a()],A.prototype,"type",null),e([a()],A.prototype,"valid",null),e([a({value:null})],A.prototype,"value",null),e([a()],A.prototype,"visible",null),A=e([u("esri.widgets.FeatureForm.InputField")],A);const N=A;export{N as default};