@arcgis/core 4.26.0 → 4.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/arcade/ArcadeDate.js +1 -1
  2. package/arcade/Feature.js +1 -1
  3. package/arcade/arcadeTimeUtils.js +1 -1
  4. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  5. package/assets/esri/core/workers/RemoteClient.js +1 -1
  6. package/assets/esri/core/workers/chunks/009cd8f27d2357ec9317.js +1 -0
  7. package/assets/esri/core/workers/chunks/03081e28fe59ba2e8040.js +1 -0
  8. package/assets/esri/core/workers/chunks/17ce4b146825adcca307.js +1 -0
  9. package/assets/esri/core/workers/chunks/186f2d0c94fa1eca4959.js +1 -0
  10. package/assets/esri/core/workers/chunks/1fd48420dfbbfdb3b051.js +1 -0
  11. package/assets/esri/core/workers/chunks/226bfa115acb8542f21c.js +1 -0
  12. package/assets/esri/core/workers/chunks/{25abc848a128b24ff66e.js → 3808f33563757fad703d.js} +1 -1
  13. package/assets/esri/core/workers/chunks/38ebf5d20576609566f9.js +1 -0
  14. package/assets/esri/core/workers/chunks/4125b10b1d009f35e75e.js +1 -0
  15. package/assets/esri/core/workers/chunks/47195afa66f640cb4b64.js +1 -0
  16. package/assets/esri/core/workers/chunks/48d35993b6ffb76e56e9.js +1 -0
  17. package/assets/esri/core/workers/chunks/5022862c5658e7bb0e04.js +1 -0
  18. package/assets/esri/core/workers/chunks/55782608bee89fa0d6e1.js +1 -0
  19. package/assets/esri/core/workers/chunks/5598996bcf60741aa734.js +1 -0
  20. package/assets/esri/core/workers/chunks/592e9834aa896cdd0e86.js +1 -0
  21. package/assets/esri/core/workers/chunks/5a5e4983c526bf08c7f1.js +1 -0
  22. package/assets/esri/core/workers/chunks/{a6d34147e7dbb1e4609c.js → 5f8acce073b8da5ac6ae.js} +1 -1
  23. package/assets/esri/core/workers/chunks/611c27efa10e4e04d8b6.js +1 -0
  24. package/assets/esri/core/workers/chunks/6ecf0bb8e16159160cde.js +1 -0
  25. package/assets/esri/core/workers/chunks/81949c9d14a8d75c45b6.js +1 -0
  26. package/assets/esri/core/workers/chunks/843a8b87ebecc246598a.js +1 -0
  27. package/assets/esri/core/workers/chunks/84c0a8d41eec91bb5142.js +1 -0
  28. package/assets/esri/core/workers/chunks/85c6a2c7239d0cf73a44.js +1 -0
  29. package/assets/esri/core/workers/chunks/8f3262f33d635cf9f046.js +1 -0
  30. package/assets/esri/core/workers/chunks/9054fd0707a15d037bb9.js +1 -0
  31. package/assets/esri/core/workers/chunks/a2e5b67c1c65a93f3c75.js +1 -0
  32. package/assets/esri/core/workers/chunks/b8b6df646ecf5482c5b4.js +1 -0
  33. package/assets/esri/core/workers/chunks/bcdd71e7475777f0f1bb.js +1 -0
  34. package/assets/esri/core/workers/chunks/{97ba79f9bceb42405573.js → bce1d4d6449a646834a1.js} +1 -1
  35. package/assets/esri/core/workers/chunks/bdeb15d8c536cc64f8da.js +1 -0
  36. package/assets/esri/core/workers/chunks/c999e9dd748ae449d66e.js +1 -0
  37. package/assets/esri/core/workers/chunks/cb177fb86cf8cec95e87.js +1 -0
  38. package/assets/esri/core/workers/chunks/{3c557a5728c76843561f.js → d3498d28fd01a0ad3899.js} +1 -1
  39. package/assets/esri/core/workers/chunks/dd698ada6b7c03cfd25c.js +1 -0
  40. package/assets/esri/core/workers/chunks/e26acb83eae5eec87ca1.js +1 -0
  41. package/assets/esri/core/workers/chunks/eca1b840c009e5477b80.js +1 -0
  42. package/assets/esri/core/workers/chunks/fbe981e42e92a32d922d.js +1 -0
  43. package/config.js +1 -1
  44. package/core/string.js +1 -1
  45. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  46. package/layers/support/PixelBlock.js +1 -1
  47. package/package.json +1 -1
  48. package/support/revision.js +1 -1
  49. package/views/2d/engine/ImageryBitmapSource.js +1 -1
  50. package/views/2d/layers/features/sources/BaseFeatureSource.js +1 -1
  51. package/views/2d/layers/features/sources/DataTileSource.js +1 -1
  52. package/views/layers/ImageryTileLayerView.js +1 -1
  53. package/widgets/Editor.js +1 -1
  54. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  55. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  56. package/widgets/FeatureForm.js +1 -1
  57. package/assets/esri/core/workers/chunks/03a811b5a912d83792dd.js +0 -1
  58. package/assets/esri/core/workers/chunks/0923c0641ca9d9a52efc.js +0 -1
  59. package/assets/esri/core/workers/chunks/1aff09c90f287eeba408.js +0 -1
  60. package/assets/esri/core/workers/chunks/1faf0e2aeabe003e2f64.js +0 -1
  61. package/assets/esri/core/workers/chunks/28a17bb249893350c2bf.js +0 -1
  62. package/assets/esri/core/workers/chunks/29662688eedc6df54d4b.js +0 -1
  63. package/assets/esri/core/workers/chunks/2b94b1bc4634f0518890.js +0 -1
  64. package/assets/esri/core/workers/chunks/3664d97f0c2819690cf9.js +0 -1
  65. package/assets/esri/core/workers/chunks/3d457f987e2089d67e89.js +0 -1
  66. package/assets/esri/core/workers/chunks/41d25407888326c91566.js +0 -1
  67. package/assets/esri/core/workers/chunks/4503194b1b1d8908a386.js +0 -1
  68. package/assets/esri/core/workers/chunks/4a264b7cfd0a4bc62be9.js +0 -1
  69. package/assets/esri/core/workers/chunks/4cddaa79af86b0981baa.js +0 -1
  70. package/assets/esri/core/workers/chunks/582d12138e6eea62d6fe.js +0 -1
  71. package/assets/esri/core/workers/chunks/5e9869849d999aac5756.js +0 -1
  72. package/assets/esri/core/workers/chunks/636b4e080d701d5856c7.js +0 -1
  73. package/assets/esri/core/workers/chunks/69c89c01783250811b56.js +0 -1
  74. package/assets/esri/core/workers/chunks/72c827a5388a4b1112e3.js +0 -1
  75. package/assets/esri/core/workers/chunks/7db8a429ef7bf11c5bb6.js +0 -1
  76. package/assets/esri/core/workers/chunks/8d52093b6c4bfd087a12.js +0 -1
  77. package/assets/esri/core/workers/chunks/9b449a036598479ad0b0.js +0 -1
  78. package/assets/esri/core/workers/chunks/9c67598554e0d2b2c14a.js +0 -1
  79. package/assets/esri/core/workers/chunks/9f8aad19c5973e201604.js +0 -1
  80. package/assets/esri/core/workers/chunks/9ff12db2f3dcd5749053.js +0 -1
  81. package/assets/esri/core/workers/chunks/a0e3b837262d6d64f605.js +0 -1
  82. package/assets/esri/core/workers/chunks/a213fb1cd2b5da2b7027.js +0 -1
  83. package/assets/esri/core/workers/chunks/aa864f9ad6b9a92ab328.js +0 -1
  84. package/assets/esri/core/workers/chunks/bb6e4affafef9855b8fd.js +0 -1
  85. package/assets/esri/core/workers/chunks/bd711b7229aa5cfa063b.js +0 -1
  86. package/assets/esri/core/workers/chunks/e384e1daec50f8cdcdd1.js +0 -1
  87. package/assets/esri/core/workers/chunks/eccc725bc3f8047171f7.js +0 -1
  88. package/assets/esri/core/workers/chunks/f3b59aa3b33e3ee70bec.js +0 -1
  89. package/assets/esri/core/workers/chunks/f7ed302a233d4cfb9060.js +0 -1
  90. package/assets/esri/core/workers/chunks/fd03ba4613f8973f8c86.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.26/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 s from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import i from"../../core/Logger.js";import{destroyMaybe as o,isSome as a,isNone as r,unwrap as l}from"../../core/maybe.js";import{EsriPromiseMixin as u}from"../../core/Promise.js";import{watch as p}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as g}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{isGroupField as y,getNormalizedFeatureTypeInfo as _}from"./featureFormUtils.js";import{createFormExpressionArcadeExecutor as F}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as C}from"./FormExpressionsManager.js";import v from"./InputField.js";import E from"./InputFieldGroup.js";import{onLocaleChange as x}from"../../intl/locale.js";import{fetchMessageBundle as I}from"../../intl/messages.js";const V=new t({attributes:{}}),b=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],j=["visibilityExpression"],w="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",A="#JSAPI_CONTINGENT_VALUE_ANY_HASH",M="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let T=class extends(n(u(s.EventedAccessor))){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=V.clone(),this._initialFeature=V.clone(),this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.inputFields=[],this.messages=null,this.strict=!1}initialize(){const e=async()=>{const e=await I("esri/widgets/FeatureForm/t9n/FeatureForm");this.messages=e;for(const t of this.allInputFields)t.messages=e};e();const t=p((()=>[this.layer,this.layer?.loaded,this.formTemplate]),(([e,t])=>{a(e)&&(t?this._updateInputFields():e.load().catch((()=>i.getLogger(this.declaredClass).error("Failed to load layer",e.loadError))))}),{equals:([e,t,s],[n,i,o])=>e===n&&t===i&&s===o,initial:!0}),s=p((()=>this._arcadeContextInfo),(e=>{a(this._expressionsManager)&&(this._expressionsManager.arcadeContextInfo=e)})),n=p((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.handles.add([x(e),t,s,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache)}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:s,spatialReference:n,view:i}=this;return{layer:g(s)?s:null,originalFeature:e,editType:t,spatialReference:n,map:i?.map}}get updating(){return this.updatingHandles.updating}get allInputFields(){return L(this.inputFields)}get _layerFieldsByName(){return new Map(this.layer.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():V.clone(),this._initialFeature=this._featureClone.clone(),this._resetInputFieldValues(this._featureClone),this.contingencyConstraintViolations.clear(),a(this._expressionsManager)&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this.updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(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 joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}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 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){const{_featureClone:t,layer:s}=this,n=!!s?.getField(e);return t.getAttribute(e)??(n?null:void 0)}setValue(e,t){const{_featureClone:s,strict:n}=this,i=this.findField(e);t=""===t?null:t,i&&s.getAttribute(e)!==t&&(i.value=t,n&&!i.valid||(this._afterValueChange(i),a(this._expressionsManager)&&this.updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allInputFields,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),s=e.filter((e=>!e.valid)).map((({name:e})=>e)),n=this.getValues();if(this.validateContingencyConstraints(n,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),s.push(i));this.emit("submit",{valid:[...t],invalid:s,values:n})}validateContingencyConstraints(e,t){const{_contingentValuesCache:s}=this,n=new Map;if(this.contingencyConstraintViolations=n,r(s))return[];const{invalid:i,incomplete:o}=s.validateContingencyConstraints(e),a=[...i,...t?.includeIncompleteViolations?o:[]];for(const r of a)for(const e of r.fieldGroup.fields)n.set(e,r);return a}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:s}=this;s.geometry=t.geometry,a(e)&&this.updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:s}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:s,valid:t})}_updateInputFields(){const{_featureClone:e,_initialFeature:t,arcadeEditType:s,formTemplate:n,inputFields:i,messages:o,layer:r}=this,l={arcadeEditType:s,feature:e,initialFeature:t,layer:r,messages:o},u=i.slice(),p=a(n)&&n.elements.length>0?this._updateInputFieldsFromElements(u,n.elements,l):this._updateInputFieldsFromLayerFields(u,r?.fields,l);this.inputFields=p}_updateInputFieldsFromElements(e,t,s){const n=new Map;for(const a of e)if(y(a)){N(n,a.groupElement,a);for(const e of a.inputFields)N(n,e.fieldElement,e)}else N(n,a.fieldElement,a);const i=new Map,o=this._updateInputFieldsRecursive({existingInputFieldsByElement:n,updatedElements:t.filter(this._isSupportedElement),sharedInitializationProperties:s,group:null,newExpressionExecutorPromises:i});this.updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=L(o);return this._createExpressionsManager(e,t),l(this._expressionsManager).evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[a,r]of n.entries())n.delete(a),r.destroy();return o}_updateInputFieldsRecursive(e){const{existingInputFieldsByElement:t,updatedElements:s,sharedInitializationProperties:n,group:i,newExpressionExecutorPromises:o}=e,a=[];for(const r of s){const e=t.has(r),s=e?t.get(r):S(r)?this._makeInputFieldGroupFromGroupElement(r,n):this._makeInputFieldFromFieldElement(r,n,i);if(a.push(s),e)if(t.delete(r),y(s)){const{feature:e}=n;s.set({feature:e})}else s.set(n);else this._assignExpressionExecutors(s,r,o);if(S(r)){const e=r.elements.filter((e=>this._isSupportedElement(e)));s.inputFields=this._updateInputFieldsRecursive({existingInputFieldsByElement:t,updatedElements:e,sharedInitializationProperties:n,group:s,newExpressionExecutorPromises:o})}}return a}_updateInputFieldsFromLayerFields(e,t,s){if(!Array.isArray(t))return i.getLogger(this.declaredClass).warn(this.declaredClass,"No attribute fields found."),[];const n=new Map;for(const i of e)if(y(i)){for(const e of i.inputFields)e.destroy();i.inputFields.length=0,i.destroy()}else a(i.fieldElement)?i.destroy():n.set(i.field,i);const o=[],{arcadeEditType:r,feature:l,initialFeature:u,layer:p,messages:d}=s;for(const i of t){const e=n.get(i)??new v({arcadeEditType:r,field:i,feature:l,initialFeature:u,layer:p,messages:d,value:l.getAttribute(i.name)??null});o.push(e),n.delete(i)}for(const[i,a]of n.entries())n.delete(i),a.destroy();return o}_resetInputFieldValues(e){for(const t of this.allInputFields)t.value=e.getAttribute(t.name)}_makeInputFieldFromFieldElement(e,t,s=null){const{arcadeEditType:n,feature:i,initialFeature:o,layer:a,messages:r}=t;return new v({arcadeEditType:n,fieldElement:e,field:this._layerFieldsByName.get(e.fieldName),value:i.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:a,group:s,messages:r})}_makeInputFieldGroupFromGroupElement(e,t){const{feature:s,initialFeature:n}=t;return new E({groupElement:e,inputFields:[],feature:s,initialFeature:n})}_assignExpressionExecutors(e,t,s){const n=S(t)?j:b,i=[];for(const o of n){const n=t[o],{_expressionExecutorLookup:i}=this;if(a(n)&&""!==n){const t=`${o}Executor`,a=this._expressionLookup.get(n)??this._addToExpressionLookup(n);if(i.has(a))e[t]=i.get(a);else if(s.has(a)){const n=s.get(a).then((s=>(e[t]=s,s)));s.set(a,n)}else{const n=F(a,this.layer).then((s=>(e[t]=s,i.set(a,s),s)));s.set(a,n)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:s,_featureClone:n}=this;this._expressionsManager=new C({executors:e,feature:n,arcadeContextInfo:s,inputFields:t})}_afterValueChange(e){const{name:t,value:s}=e,{_featureClone:n}=this,i=n.getAttribute(t);n.setAttribute(t,s);const{typeFieldName:o,types:a}=_(this.layer);if(t===o&&s!==i){if("subtype-sublayer"===this.layer.type){const e=this.layer.parent?.findSublayerForFeature(n);n.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of a)if(t.domains&&"object"==typeof t.domains)for(const s of Object.keys(t.domains))e.add(s);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allInputFields)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:s}=this,n=(a(s)&&a(s.expressionInfos)?Object.values(s.expressionInfos).find((t=>t.name===e)):null)?.expression??e;return t.set(e,n),e!==n&&t.set(n,n),n}_isSupportedElement(e){return"field"===e.type||"group"===e.type||(i.getLogger(this.declaredClass).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{typeFieldName:t}=_(this.layer),s=t?this.getValue(t):null,n=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const n of e)n.isRetired||a(n.subtype)&&n.subtype.code!==s||o.push({values:n.values});o.length>0&&n.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(n);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,s=[],n=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,a=[i.name,o.name].sort().join("|");if(n.has(a))continue;s.push([i,o]),n.add(a),t.set(e,o)}else t.set(e,l);const i=new Set(s.flat()),o=new Set(e);for(const l of i)o.delete(l);const a=new Map,r=new Map;for(const l of new Set(s.flat())){const e=Symbol(l.name);a.set(e,new Set([l])),r.set(l,e)}for(const[l,u]of s){const e=r.get(l),t=r.get(u);if(e===t)continue;const s=a.get(e),n=a.get(t);for(const i of n)s.add(i),r.set(i,e);a.delete(t)}return[[...a.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),s=t.shift();let n=t.shift(),i=this._generateJoinKey(s.fields,n.fields),o=new Set([...s.fields,...n.fields]),l=new Map;for(const a of s.contingencies){const[e]=this._hashContingency(a,i.codedValueFields,!0);l.has(e)?l.get(e).push(a):l.set(e,[a])}for(;t.length>0;){const e=new Map,s=t.shift(),a=this._generateJoinKey(o,s.fields);for(const t of n.contingencies){const[s,n]=this._hashContingency(t,i.codedValueFields),o=n?this._findMatchingContingenciesWithAnyHashMask(l,s):l.get(s);if(l.has(A)&&o.push(...this._findMatchingContingenciesContainingAny(t,l.get(A),i.codedValueFields)),!r(o))for(const l of o){const s=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(l,t,i.rangeFields):this._joinContingencies(l,t);if(r(s))break;const[n]=this._hashContingency(s,a.codedValueFields,!0);e.has(n)?e.get(n).push(s):e.set(n,[s])}}l=e,n=s,i=a,o=new Set([...o,...n.fields])}const u=[];for(const p of n.contingencies){const[e,t]=this._hashContingency(p,i.codedValueFields),s=t?this._findMatchingContingenciesWithAnyHashMask(l,e):l.get(e);if(l.has(A)&&s.push(...this._findMatchingContingenciesContainingAny(p,l.get(A),i.codedValueFields)),!r(s))for(const n of s){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(n,p,i.rangeFields):this._joinContingencies(n,p);a(e)&&u.push(e)}}return u}_joinContingencies(e,t){const s={values:{...e.values,...t.values}};for(const[n,i]of Object.entries(s.values))"any"===i.objectType&&a(e.values[n])&&(s.values[n]=e.values[n]);return s}_joinContingenciesWithRangeDomains(e,t,s){const n=this._joinContingencies(e,t);for(const i of s){const s=e.values[i],o=t.values[i],{leftIsNull:a,rightIsNull:r,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:d,leftIsRange:c,rightIsRange:f}=this._compareObjectTypes(s.objectType,o.objectType);if(l||d)continue;if(a&&p||r&&u){n.values[i]=new h({objectType:"null"});continue}if(a&&f||r&&c)return null;u?(s.minValue=-1/0,s.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const g=Math.max(s.minValue,o.minValue),m=Math.min(s.maxValue,o.maxValue);if(g>m)return null;n.values[i]=new h({objectType:"range",minValue:g,maxValue:m})}return n}_findMatchingContingenciesContainingAny(e,t,s){return t.filter((t=>s.every((s=>{const n=t.values[s],i=e.values[s];return"any"===n.objectType||"any"===i.objectType||n.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const s=RegExp(`${t}$`),n=[];for(const[i,o]of e){if(i===A)break;s.test(i)&&n.push(...o)}return n}_generateJoinKey(e,t){const s=Array.isArray(e)?new Set(e):e,n=Array.isArray(t)?new Set(t):t,i=s.size<n.size?s:n,o=i===s?n:s,a=new Set,l=new Set;for(const u of i)if(o.has(u)){const e=this.layer.getFieldDomain(u,{feature:this.feature});if(r(e))continue;switch(e.type){case"coded-value":a.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...a],rangeFields:[...l]}}_hashContingency(e,t,s=!1){if(t.length<1)return[w,!1];const n=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(s)return[A,!0];i=!0,n.push(`${o}:.*`)}else"null"===t.objectType?n.push(`${o}:${M}`):n.push(`${o}:${t.codedValue?.code}`)}return[n.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};e([d()],T.prototype,"_featureClone",void 0),e([d()],T.prototype,"_arcadeContextInfo",null),e([d()],T.prototype,"updating",null),e([d({readOnly:!0})],T.prototype,"allInputFields",null),e([d()],T.prototype,"_layerFieldsByName",null),e([d()],T.prototype,"arcadeEditType",void 0),e([d()],T.prototype,"contingencyConstraintViolations",void 0),e([d()],T.prototype,"feature",null),e([d()],T.prototype,"fieldsWithContingentValues",null),e([d({type:f})],T.prototype,"formTemplate",null),e([d()],T.prototype,"inputFields",void 0),e([d()],T.prototype,"joinedContingentValues",null),e([d()],T.prototype,"layer",null),e([d()],T.prototype,"messages",void 0),e([d()],T.prototype,"spatialReference",null),e([d()],T.prototype,"state",null),e([d()],T.prototype,"strict",void 0),e([d()],T.prototype,"submittable",null),e([d()],T.prototype,"valid",null),e([d()],T.prototype,"view",void 0),e([d()],T.prototype,"getValues",null),e([d()],T.prototype,"submit",null),T=e([c("esri.widgets.FeatureForm.FeatureFormViewModel")],T);const S=e=>"group"===e.type,L=e=>e.reduce(((e,t)=>y(t)?[...e,...t.inputFields]:[...e,t]),[]),N=(e,t,s)=>{a(t)&&e.set(t,s)},k=T;export{k as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import i from"../../core/Logger.js";import{destroyMaybe as o,isSome as r,isNone as a,unwrap as l}from"../../core/maybe.js";import{EsriPromiseMixin as u}from"../../core/Promise.js";import{watch as p}from"../../core/reactiveUtils.js";import{templateHasKey as d}from"../../core/string.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../form/FormTemplate.js";import g from"../../layers/support/ContingentValue.js";import{isEditableLayer as m}from"../../layers/support/editableLayers.js";import y from"../../layers/support/LayerContingentValuesCache.js";import{parseFormTemplateString as _,isGroupField as F,getNormalizedFeatureTypeInfo as C}from"./featureFormUtils.js";import{createFormExpressionArcadeExecutor as v}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as E}from"./FormExpressionsManager.js";import x from"./InputField.js";import I from"./InputFieldGroup.js";import{onLocaleChange as V}from"../../intl/locale.js";import{fetchMessageBundle as b}from"../../intl/messages.js";const j=new t({attributes:{}}),w=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],T=["visibilityExpression"],A="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",M="#JSAPI_CONTINGENT_VALUE_ANY_HASH",S="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let L=class extends(n(u(s.EventedAccessor))){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=j.clone(),this._initialFeature=j.clone(),this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.inputFields=[],this.messages=null,this.strict=!1,this._isSupportedElement=this._isSupportedElement.bind(this)}initialize(){const e=async()=>{const e=await b("esri/widgets/FeatureForm/t9n/FeatureForm");this.messages=e;for(const t of this.allInputFields)t.messages=e};e();const t=p((()=>[this.layer,this.layer?.loaded,this.formTemplate]),(([e,t])=>{r(e)&&(t?this._updateInputFields():e.load().catch((()=>i.getLogger(this.declaredClass).error("Failed to load layer",e.loadError))))}),{equals:([e,t,s],[n,i,o])=>e===n&&t===i&&s===o,initial:!0}),s=p((()=>this._arcadeContextInfo),(e=>{r(this._expressionsManager)&&(this._expressionsManager.arcadeContextInfo=e)})),n=p((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(y.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.handles.add([V(e),t,s,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache)}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:s,spatialReference:n,view:i}=this;return{layer:m(s)?s:null,originalFeature:e,editType:t,spatialReference:n,map:i?.map}}get updating(){return this.updatingHandles.updating}get allInputFields(){return k(this.inputFields)}get _layerFieldsByName(){return new Map(this.layer.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():j.clone(),this._initialFeature=this._featureClone.clone(),this._resetInputFieldValues(this._featureClone),this.contingencyConstraintViolations.clear(),r(this._expressionsManager)&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this.updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(a(this._contingentValuesCache))return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return!a(e)&&e.description&&t?_(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return!a(e)&&e.title&&t?_(e.title,this.getValues(),t.fieldsIndex):null}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}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 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){const{_featureClone:t,layer:s}=this,n=!!s?.getField(e);return t.getAttribute(e)??(n?null:void 0)}setValue(e,t){const{_featureClone:s,strict:n}=this,i=this.findField(e);t=""===t?null:t,i&&s.getAttribute(e)!==t&&(i.value=t,n&&!i.valid||(this._afterValueChange(i),r(this._expressionsManager)&&this.updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allInputFields,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),s=e.filter((e=>!e.valid)).map((({name:e})=>e)),n=this.getValues();if(this.validateContingencyConstraints(n,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),s.push(i));this.emit("submit",{valid:[...t],invalid:s,values:n})}validateContingencyConstraints(e,t){const{_contingentValuesCache:s}=this,n=new Map;if(this.contingencyConstraintViolations=n,a(s))return[];const{invalid:i,incomplete:o}=s.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)n.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:s}=this;s.geometry=t.geometry,r(e)&&this.updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:s}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:s,valid:t})}_updateInputFields(){const{_featureClone:e,_initialFeature:t,arcadeEditType:s,formTemplate:n,inputFields:i,messages:o,layer:a}=this,l={arcadeEditType:s,feature:e,initialFeature:t,layer:a,messages:o},u=i.slice(),p=r(n)&&n.elements.length>0?this._updateInputFieldsFromElements(u,n.elements,l):this._updateInputFieldsFromLayerFields(u,a?.fields,l);this.inputFields=p}_updateInputFieldsFromElements(e,t,s){const n=new Map;for(const r of e)if(F(r)){R(n,r.groupElement,r);for(const e of r.inputFields)R(n,e.fieldElement,e)}else R(n,r.fieldElement,r);const i=new Map,o=this._updateInputFieldsRecursive({existingInputFieldsByElement:n,updatedElements:t.filter(this._isSupportedElement),sharedInitializationProperties:s,group:null,newExpressionExecutorPromises:i});this.updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=k(o);return this._createExpressionsManager(e,t),l(this._expressionsManager).evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[r,a]of n.entries())n.delete(r),a.destroy();return o}_updateInputFieldsRecursive(e){const{existingInputFieldsByElement:t,updatedElements:s,sharedInitializationProperties:n,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of s){const e=t.has(a),s=e?t.get(a):N(a)?this._makeInputFieldGroupFromGroupElement(a,n):this._makeInputFieldFromFieldElement(a,n,i);if(r.push(s),e)if(t.delete(a),F(s)){const{feature:e}=n;s.set({feature:e})}else s.set(n);else this._assignExpressionExecutors(s,a,o);if(N(a)){const e=a.elements.filter((e=>this._isSupportedElement(e)));s.inputFields=this._updateInputFieldsRecursive({existingInputFieldsByElement:t,updatedElements:e,sharedInitializationProperties:n,group:s,newExpressionExecutorPromises:o})}}return r}_updateInputFieldsFromLayerFields(e,t,s){if(!Array.isArray(t))return i.getLogger(this.declaredClass).warn(this.declaredClass,"No attribute fields found."),[];const n=new Map;for(const i of e)if(F(i)){for(const e of i.inputFields)e.destroy();i.inputFields.length=0,i.destroy()}else r(i.fieldElement)?i.destroy():n.set(i.field,i);const o=[],{arcadeEditType:a,feature:l,initialFeature:u,layer:p,messages:d}=s;for(const i of t){const e=n.get(i)??new x({arcadeEditType:a,field:i,feature:l,initialFeature:u,layer:p,messages:d,value:l.getAttribute(i.name)??null});o.push(e),n.delete(i)}for(const[i,r]of n.entries())n.delete(i),r.destroy();return o}_resetInputFieldValues(e){for(const t of this.allInputFields)t.value=e.getAttribute(t.name)}_makeInputFieldFromFieldElement(e,t,s=null){const{arcadeEditType:n,feature:i,initialFeature:o,layer:r,messages:a}=t;return new x({arcadeEditType:n,fieldElement:e,field:this._layerFieldsByName.get(e.fieldName),value:i.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:s,messages:a})}_makeInputFieldGroupFromGroupElement(e,t){const{feature:s,initialFeature:n}=t;return new I({groupElement:e,inputFields:[],feature:s,initialFeature:n})}_assignExpressionExecutors(e,t,s){const n=N(t)?T:w,i=[];for(const o of n){const n=t[o],{_expressionExecutorLookup:i}=this;if(r(n)&&""!==n){const t=`${o}Executor`,r=this._expressionLookup.get(n)??this._addToExpressionLookup(n);if(i.has(r))e[t]=i.get(r);else if(s.has(r)){const n=s.get(r).then((s=>(e[t]=s,s)));s.set(r,n)}else{const n=v(r,this.layer).then((s=>(e[t]=s,i.set(r,s),s)));s.set(r,n)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:s,_featureClone:n}=this;this._expressionsManager=new E({executors:e,feature:n,arcadeContextInfo:s,inputFields:t})}_afterValueChange(e){const{name:t,value:s}=e,{_featureClone:n,formTemplate:i,layer:o}=this;if(!o)return;const a=n.getAttribute(t);n.setAttribute(t,s);const{typeFieldName:l,types:u}=C(o);if(t===l&&s!==a){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(n);n.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of u)if(t.domains&&"object"==typeof t.domains)for(const s of Object.keys(t.domains))e.add(s);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(r(i)){const{description:e,title:s}=i;s&&d(s,t)&&this.notifyChange("formTitle"),e&&d(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allInputFields)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:s}=this,n=(r(s)&&r(s.expressionInfos)?Object.values(s.expressionInfos).find((t=>t.name===e)):null)?.expression??e;return t.set(e,n),e!==n&&t.set(n,n),n}_isSupportedElement(e){return"field"===e.type||"group"===e.type||(i.getLogger(this.declaredClass).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(a(e))return[];const{typeFieldName:t}=C(this.layer),s=t?this.getValue(t):null,n=[];for(const a of e.fieldGroups){const{contingencies:e,fields:t,name:i}=a,o=[];for(const n of e)n.isRetired||r(n.subtype)&&n.subtype.code!==s||o.push({values:n.values});o.length>0&&n.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(n);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,s=[],n=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(n.has(r))continue;s.push([i,o]),n.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(s.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(s.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of s){const e=a.get(l),t=a.get(u);if(e===t)continue;const s=r.get(e),n=r.get(t);for(const i of n)s.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),s=t.shift();let n=t.shift(),i=this._generateJoinKey(s.fields,n.fields),o=new Set([...s.fields,...n.fields]),l=new Map;for(const r of s.contingencies){const[e]=this._hashContingency(r,i.codedValueFields,!0);l.has(e)?l.get(e).push(r):l.set(e,[r])}for(;t.length>0;){const e=new Map,s=t.shift(),r=this._generateJoinKey(o,s.fields);for(const t of n.contingencies){const[s,n]=this._hashContingency(t,i.codedValueFields),o=n?this._findMatchingContingenciesWithAnyHashMask(l,s):l.get(s);if(l.has(M)&&o.push(...this._findMatchingContingenciesContainingAny(t,l.get(M),i.codedValueFields)),!a(o))for(const l of o){const s=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(l,t,i.rangeFields):this._joinContingencies(l,t);if(a(s))break;const[n]=this._hashContingency(s,r.codedValueFields,!0);e.has(n)?e.get(n).push(s):e.set(n,[s])}}l=e,n=s,i=r,o=new Set([...o,...n.fields])}const u=[];for(const p of n.contingencies){const[e,t]=this._hashContingency(p,i.codedValueFields),s=t?this._findMatchingContingenciesWithAnyHashMask(l,e):l.get(e);if(l.has(M)&&s.push(...this._findMatchingContingenciesContainingAny(p,l.get(M),i.codedValueFields)),!a(s))for(const n of s){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(n,p,i.rangeFields):this._joinContingencies(n,p);r(e)&&u.push(e)}}return u}_joinContingencies(e,t){const s={values:{...e.values,...t.values}};for(const[n,i]of Object.entries(s.values))"any"===i.objectType&&r(e.values[n])&&(s.values[n]=e.values[n]);return s}_joinContingenciesWithRangeDomains(e,t,s){const n=this._joinContingencies(e,t);for(const i of s){const s=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:d,leftIsRange:c,rightIsRange:f}=this._compareObjectTypes(s.objectType,o.objectType);if(l||d)continue;if(r&&p||a&&u){n.values[i]=new g({objectType:"null"});continue}if(r&&f||a&&c)return null;u?(s.minValue=-1/0,s.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const h=Math.max(s.minValue,o.minValue),m=Math.min(s.maxValue,o.maxValue);if(h>m)return null;n.values[i]=new g({objectType:"range",minValue:h,maxValue:m})}return n}_findMatchingContingenciesContainingAny(e,t,s){return t.filter((t=>s.every((s=>{const n=t.values[s],i=e.values[s];return"any"===n.objectType||"any"===i.objectType||n.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const s=RegExp(`${t}$`),n=[];for(const[i,o]of e){if(i===M)break;s.test(i)&&n.push(...o)}return n}_generateJoinKey(e,t){const s=Array.isArray(e)?new Set(e):e,n=Array.isArray(t)?new Set(t):t,i=s.size<n.size?s:n,o=i===s?n:s,r=new Set,l=new Set;for(const u of i)if(o.has(u)){const e=this.layer.getFieldDomain(u,{feature:this.feature});if(a(e))continue;switch(e.type){case"coded-value":r.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...r],rangeFields:[...l]}}_hashContingency(e,t,s=!1){if(t.length<1)return[A,!1];const n=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(s)return[M,!0];i=!0,n.push(`${o}:.*`)}else"null"===t.objectType?n.push(`${o}:${S}`):n.push(`${o}:${t.codedValue?.code}`)}return[n.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};e([c()],L.prototype,"_featureClone",void 0),e([c()],L.prototype,"_arcadeContextInfo",null),e([c()],L.prototype,"updating",null),e([c({readOnly:!0})],L.prototype,"allInputFields",null),e([c()],L.prototype,"_layerFieldsByName",null),e([c()],L.prototype,"arcadeEditType",void 0),e([c()],L.prototype,"contingencyConstraintViolations",void 0),e([c()],L.prototype,"feature",null),e([c()],L.prototype,"fieldsWithContingentValues",null),e([c({type:h})],L.prototype,"formTemplate",null),e([c()],L.prototype,"formDescription",null),e([c()],L.prototype,"formTitle",null),e([c()],L.prototype,"inputFields",void 0),e([c()],L.prototype,"joinedContingentValues",null),e([c()],L.prototype,"layer",null),e([c()],L.prototype,"messages",void 0),e([c()],L.prototype,"spatialReference",null),e([c()],L.prototype,"state",null),e([c()],L.prototype,"strict",void 0),e([c()],L.prototype,"submittable",null),e([c()],L.prototype,"valid",null),e([c()],L.prototype,"view",void 0),e([c()],L.prototype,"getValues",null),e([c()],L.prototype,"submit",null),L=e([f("esri.widgets.FeatureForm.FeatureFormViewModel")],L);const N=e=>"group"===e.type,k=e=>e.reduce(((e,t)=>F(t)?[...e,...t.inputFields]:[...e,t]),[]),R=(e,t,s)=>{r(t)&&e.set(t,s)},P=L;export{P 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.26/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as e}from"../../core/maybe.js";const p=e=>!!e.inputFields,t=(p,t)=>e(p)&&p.input?.type===t,y={typeFieldName:null,types:[]},s=e=>e?"subtype-sublayer"===e.type?{typeFieldName:e.parent?.subtypeField,types:e.parent?.subtypes}:"types"in e&&e.types?{typeFieldName:e.typeIdField,types:e.types.map((({id:e,name:p,domains:t})=>({code:e,name:p,domains:t})))}:y:y;export{s as getNormalizedFeatureTypeInfo,t as isFieldElementWithInputType,p as isGroupField};
5
+ import{isSome as e}from"../../core/maybe.js";import{templateHasKey as t,replace as n}from"../../core/string.js";const o=e=>!!e.inputFields,s=(t,n)=>e(t)&&t.input?.type===n,i={typeFieldName:null,types:[]};function p(n,o,s){const i=Object.keys(o).filter((e=>t(n,e))),p=i.map((e=>o[e])),m=i.map((e=>s.get(e))).filter(e);return a(n,r(p,m))}function r(e,t){const n=t.map(((t,n)=>{let o=e[n];if(t.domain&&"coded-value"===t.domain.type){const e=t.domain.codedValues.find((e=>e.code===o));e?.name&&(o=e.name)}return[t.name,o]}));return Object.fromEntries(n)}function a(e,t){return n(n(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const m=e=>e?"subtype-sublayer"===e.type?{typeFieldName:e.parent?.subtypeField,types:e.parent?.subtypes}:"types"in e&&e.types?{typeFieldName:e.typeIdField,types:e.types.map((({id:e,name:t,domains:n})=>({code:e,name:t,domains:n})))}:i:i;export{r as getComputedAttributes,m as getNormalizedFeatureTypeInfo,s as isFieldElementWithInputType,o as isGroupField,p as parseFormTemplateString,a as substituteFieldTemplatesInString};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{neverReached as t}from"../core/compilerUtils.js";import{isSome as i,isNone as a}from"../core/maybe.js";import{watch as n}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{getDomainRange as r}from"../layers/support/domainUtils.js";import{getFieldRange as o}from"../layers/support/fieldUtils.js";import u from"./Widget.js";import{CSS as d}from"./FeatureForm/css.js";import{isGroupField as p,isFieldElementWithInputType as c}from"./FeatureForm/featureFormUtils.js";import m from"./FeatureForm/FeatureFormViewModel.js";import{Heading as h,incrementHeadingLevel as f}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{vmEvent as b}from"./support/decorators/vmEvent.js";import{tsx as v}from"./support/jsxFactory.js";import{DateTime as _}from"luxon";import{getLocale as I}from"../intl/locale.js";const F="TT",y="data-field-name",w="latn",V=e=>"valueAsDate"in e;let D=class extends u{constructor(e,t){super(e,t),this._dateInputFieldMap=new Map,this._activeInputName="",this._activeNumberFieldEdit=null,this._fieldFocusNeeded=!1,this._fieldToInitialIncompatibleDomainValue=new Map,this._switchFieldsWithInitialIncompatibleValue=new Set,this._userUpdatedInputFieldNames=new Set,this.disabled=!1,this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesTemplates=null,this.viewModel=new m,this._handleInputInput=e=>{this._commitInputValue(e.currentTarget)},this._handleFormKeyDown=this._handleFormKeyDown.bind(this),this._handleInputBlur=this._handleInputBlur.bind(this),this._handleInputFocus=this._handleInputFocus.bind(this),this._handleNumberInputMouseDown=this._handleNumberInputMouseDown.bind(this),this._handleInputKeyDown=this._handleInputKeyDown.bind(this),this._handleOptionChange=this._handleOptionChange.bind(this),this._handleGroupClick=this._handleGroupClick.bind(this),this._handleSubmit=this._handleSubmit.bind(this),this._afterInputCreateOrUpdate=this._afterInputCreateOrUpdate.bind(this),this._afterDateInputCreateOrUpdate=this._afterDateInputCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{const e=this._getFocusableInput("forward");this._activeInputName=e?.name||"",this._userUpdatedInputFieldNames.clear(),this._fieldToInitialIncompatibleDomainValue.clear(),this._switchFieldsWithInitialIncompatibleValue.clear(),this._dateInputFieldMap.clear(),this._fieldFocusNeeded=!0})),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._userUpdatedInputFieldNames.add(e))),this._activeInputName=t,this._fieldFocusNeeded=!0,this.scheduleRender()}}))])}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-combobox.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),import("@esri/calcite-components/dist/components/calcite-input-message.js"),import("@esri/calcite-components/dist/components/calcite-progress.js"),import("@esri/calcite-components/dist/components/calcite-switch.js"),import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),import("@esri/calcite-components/dist/components/calcite-input-time-picker.js")])}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return v("div",{class:this.classes(d.base,d.widget,d.panel)},"ready"===e?this.renderForm():null)}renderForm(){const{formTemplate:e}=this,t=i(e)&&e.title&&v(h,{key:"title",level:this.headingLevel},e.title),a=i(e)&&e.description&&v("p",{class:d.description,key:"description"},e.description),n=t||a?v("div",{class:d.formHeader},t,a):null;return v("form",{class:d.form,novalidate:!0,onsubmit:this._handleSubmit,onkeydown:this._handleFormKeyDown},n,this.renderFields())}renderFields(){const{viewModel:{inputFields:e}}=this;return e.filter((e=>e.visible)).map(((e,t)=>p(e)?this.renderGroup(e,t):this.renderLabeledField(e)))}renderGroup(e,t){const{formTemplate:a,disabled:n}=this,{description:s,inputFields:l,label:r,state:o}=e,u=l.filter((e=>e.visible)),p=this.viewModel.findField(this._activeInputName),c=!(!p||p.group!==e),m=`${this.id}_group_${t}`,g=`${this.id}_group-label_${t}`,b=`${this.id}_group-description_${t}`,_=s?v("p",{class:this.classes(d.groupDescription,d.description),id:b},s):null,I="sequential"===this.groupDisplay,F=I?c:"expanded"===o,y=F?d.collapseIcon:d.expandIcon;return v("fieldset",{"aria-expanded":F.toString(),"aria-labelledby":g,"aria-describedby":s?b:"",class:this.classes(d.group,I?d.groupSequential:null,F?null:d.groupCollapsed,c?d.groupActive:null,n?d.inputDisabled:null),disabled:n,"data-group":e,id:m,key:t,onclick:this._handleGroupClick},v("button",{role:I?"presentation":void 0,class:d.groupHeader,type:"button",tabIndex:I?-1:0},v("div",{class:d.groupTitle},v(h,{class:d.groupLabel,id:g,level:i(a)&&a.title?f(this.headingLevel):this.headingLevel},r),_),I?null:v("span",{class:this.classes(y,d.groupToggleIcon)})),u.map((e=>this.renderLabeledField(e))))}_getFocusableInput(e,t){const i=this.viewModel.allInputFields,a="forward"===e?i:i.slice().reverse();let n;if(t)if(p(t))n=a.indexOf(t.inputFields[0]);else{let i;if(this._isInputFieldInGroup(t)&&"collapsed"===t.group.state){const{inputFields:a}=t.group;i="forward"===e?a[a.length-1]:a[0]}else i=t;n=a.indexOf(i)+1}else n=0;for(let s=n;s<a.length;s++){const e=a[s];if(e.visible)return e}return null}renderLabeledField(e){const{feature:t,label:i,layer:a,type:n}=e;return v("label",{key:`${a.id}-${t.uid}-${e.name}`,class:d.label},[i,"unsupported"!==n?this.renderInputField(e):this.renderUnsupportedField(e),this.renderAuxiliaryText(e)])}renderInputField(e){const{domain:t,name:a,type:n,updating:s,value:l}=e,r=this.getCommonInputProps(e);if("coded-value"===t?.type){if(c(e.fieldElement,"switch")){const{fieldElement:t}=e;if(!(this._switchFieldsWithInitialIncompatibleValue.has(a)||null==l||t.input.onValue!==l&&t.input.offValue!==l))return this.renderSwitchInputField(e,r);this._switchFieldsWithInitialIncompatibleValue.add(a)}return"radio-buttons"===e.inputType?this.renderRadioButtonsInputField(e,t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),r):this.renderSelectInputField(e,this._getFieldValueOptions(a,t),r)}if("datetime-picker"===e.inputType||"date"===n)return this.renderDateInputField(e,r);const o="number"===n?v("input",{type:"number",...r,value:i(this._activeNumberFieldEdit)&&this._activeNumberFieldEdit.fieldName===e.name?this._activeNumberFieldEdit.value:`${r.value}`}):"text-area"===e.inputType?v("textarea",{...r}):v("input",{type:"text",...r});return s?v("div",{class:d.inputFieldWrapper},o,v("div",{class:d.inputFieldLoader},v("calcite-progress",{type:"indeterminate"}))):o}renderDateInputField(e,t){const{includeTime:a,label:n,name:s,valid:l,value:r}=e,{readOnly:o,required:u}=t,{date:p,time:c}=this._formatValueForDateInputs(r),m=i(t.max)?this._formatValueForDateInputs(t.max):void 0,h=i(t.min)?this._formatValueForDateInputs(t.min):void 0,f=m?.date??void 0,g=h?.date??void 0,b={afterCreate:this._afterDateInputCreate,afterUpdate:this._afterDateInputCreateOrUpdate,"aria-invalid":!l,label:n,numberingSystem:w,overlayPositioning:"fixed",readOnly:o,required:u,tabIndex:0,[y]:s};return v("div",{key:`${t.key}-date-time-container`,class:d.dateInputContainer},v("calcite-input-date-picker",{bind:this,...b,class:this.classes(t.class,d.inputDate),"data-date-part":"date",key:`${t.key}-date-input`,valueAsDate:p??void 0,maxAsDate:f,minAsDate:g,onCalciteInputDatePickerChange:e=>this._commitDateChanges(e.target),onblur:e=>this._commitDateChanges(e.target,!0)}),a?v("calcite-input-time-picker",{bind:this,...b,class:this.classes(t.class,d.inputTime),"data-date-part":"time",key:`${t.key}-time-input`,value:c??void 0,step:1,onCalciteInputTimePickerChange:e=>this._commitDateChanges(e.target),onfocus:e=>{e.target.calciteTimePickerEl&&(e.target.calciteTimePickerEl.showSecond=!0)},onblur:e=>this._commitDateChanges(e.target,!0)}):null)}renderUnsupportedField(e){const t=this.getCommonInputProps(e);return v("input",{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,class:this.classes(d.input,d.inputField,d.inputDisabled),onfocus:t.onfocus,readOnly:!0,tabIndex:t.tabIndex,type:"text",value:t.value,[y]:t[y]})}renderSelectInputField(e,t,i){const{value:n}=e,{messages:s,messagesTemplates:l}=this,r=t.map((e=>e.map((e=>v("calcite-combobox-item",{value:`${e.value}`,textLabel:e.name,key:`#${e.value}`,selected:n===e.value}))))),[o,u]=r;this._registerIncompatibleValue(n,t.flat(),e,(e=>{u.unshift(v("calcite-combobox-item",{value:`${e}`,textLabel:`${e}`,key:"incompatible-option",readOnly:!0}))}));const d=u.length>0?[v("calcite-combobox-item-group",{key:"recommended",label:s.recommended},o),v("calcite-combobox-item-group",{key:"other",label:l.other},u)]:o,p=a(e.fieldElement)||c(e.fieldElement,"combo-box")&&e.fieldElement.input.showNoValueOption;if(!e.required&&p){const t="",i=c(e.fieldElement,"combo-box")&&e.fieldElement.input.noValueOptionLabel||this.messages.empty;d.unshift(v("calcite-combobox-item",{value:t,textLabel:this.messages.empty,key:"empty-option"},i))}return v("calcite-combobox",{...i,selectionMode:"single",disabled:i.readOnly,allowCustomValues:!1,onCalciteComboboxChange:e=>this._handleOptionChange(e.target)},d)}_registerIncompatibleValue(e,t,i,a){const n=this._fieldToInitialIncompatibleDomainValue,s=n.has(i.name);(s||null!=e&&""!==e&&!t.some((t=>t.value===e)))&&(s||n.set(i.name,e),a?.(e))}renderRadioButtonsInputField(e,t,i){const{value:n}=e,s=t.map((t=>this.renderRadioButton({key:t.name,label:t.name,name:e.name,value:t.value,selected:t.value===n,props:i})));this._registerIncompatibleValue(n,t,e);const l=a(e.fieldElement)||c(e.fieldElement,"radio-buttons")&&e.fieldElement.input.showNoValueOption;if(!e.required&&l){const t="",a=c(e.fieldElement,"radio-buttons")&&e.fieldElement.input.noValueOptionLabel||this.messages.empty,l=n===t||null===n;s.unshift(this.renderRadioButton({key:"empty-option",label:a,name:e.name,value:t,selected:l,props:i}))}return v("div",{key:`${i.key}-radio`,class:d.inputRadioGroup},s)}renderSwitchInputField(e,t){const{value:i}=e,a=!!c(e.fieldElement,"switch")&&i===e.fieldElement.input.onValue;return v("calcite-switch",{...t,class:d.inputSwitch,onCalciteSwitchChange:e=>this._commitInputValue(e.target),checked:a,disabled:t.readOnly})}renderRadioButton({key:e,name:t,value:i,selected:a,label:n,props:s}){return v("label",{key:e,class:d.inputRadioLabel},v("input",{...s,class:d.inputRadio,name:t,type:"radio",value:i,checked:a,disabled:s.readOnly,onchange:e=>this._commitInputValue(e.target)}),n)}renderAuxiliaryText(e){const t=this._userUpdatedInputFieldNames.has(e.name)&&!e.valid?e.errorMessage:i(this.viewModel.contingencyConstraintViolations.get(e.name))?this.messages.validationErrors.valuesIncompatible:i(e.valueExpressionExecutor)&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return i(t)?v("calcite-input-message",{status:"invalid",icon:!0},t):e.description?v("div",{key:"description",class:d.description},e.description):null}getCommonInputProps(e){const{disabled:t,groupDisplay:a}=this,{editable:n,group:s,hint:l,label:r,maxLength:o,minLength:u,name:p,required:c,type:m,valid:h,value:f}=e,g=this._userUpdatedInputFieldNames.has(p),b=!n||t,v="all"===a&&i(s)&&"collapsed"===s.state;return{afterCreate:this._afterInputCreateOrUpdate,afterUpdate:this._afterInputCreateOrUpdate,"aria-invalid":h?"false":"true",class:this.classes(d.input,d.inputField,b?d.inputDisabled:null,g&&!h?d.inputInvalid:null),key:p,label:r,minlength:u>-1?`${u}`:"",maxlength:o>-1?`${o}`:"",...this._getNumberFieldConstraints(e),readOnly:b,value:null==f?"":`${f}`,[y]:p,onfocus:this._handleInputFocus,oninput:this._handleInputInput,onblur:this._handleInputBlur,onkeydown:this._handleInputKeyDown,onmousedown:"number"===m?this._handleNumberInputMouseDown:null,placeholder:"number"===m||"text"===m?l:"",required:c,tabIndex:v?-1:0}}_isInputFieldInGroup(e){return!p(e)&&i(e.group)}_handleNumberInputMouseDown({target:e}){e.focus(),this.scheduleRender()}_getFieldValueOptions(e,t){const i=t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),a=this.viewModel.fieldsWithContingentValues.has(e)?this._getContingentValueOptions(e):[];if(a.length>0){const e=new Set(a.map((e=>e.value)));return[a,i.filter((t=>!e.has(t.value)))]}return[i,[]]}_getContingentValueOptions(e){const t={};for(const s of this.viewModel.allInputFields){const{name:i,value:n}=s;!a(n)&&i!==e&&this.viewModel.fieldsWithContingentValues.has(i)&&(t[i]=n)}const i=this.viewModel.joinedContingentValues.slice(),n=new Map;for(const s of i){const i=s.values[e];if(a(i)||"code"!==i.objectType&&"null"!==i.objectType)continue;const{code:l,name:r}=i.codedValue&&"null"!==i.objectType?i.codedValue:{code:"",name:this.messages.empty};if(n.has(l))continue;Object.entries(t).every((([e,t])=>!s.values.hasOwnProperty(e)||this._valueIsValidContingentValue(t,s.values[e])))&&n.set(l,{name:r,value:l})}return[...n.values()]}_getInputFieldFromInput(e){return this.viewModel.findField(e.getAttribute(y))}_getNumberFieldConstraints(e){const t=r(e.domain)||o(e.field);return t&&t.max!==Number.MAX_VALUE&&t.min!==Number.MIN_VALUE?t:{min:null,max:null}}async _afterDateInputCreate(e){!V(e)&&i(e.value)&&"setValue"in e&&e.setValue({value:e.value,origin:"external"}),this._afterDateInputCreateOrUpdate(e)}_afterDateInputCreateOrUpdate(e){const{name:t}=this._getInputFieldFromInput(e),a=this._dateInputFieldMap.get(t),n=V(e);i(a)?n?a.date=e:a.time=e:this._dateInputFieldMap.set(t,{[n?"date":"time"]:e}),this._afterInputCreateOrUpdate(e)}_afterInputCreateOrUpdate(e){const{viewModel:t}=this,i=this._getInputFieldFromInput(e),a=t.findField(this._activeInputName),n=this._fieldToInitialIncompatibleDomainValue.get(i.name)===i.value;this._fieldFocusNeeded&&a===i&&("radio-buttons"!==i.inputType||n||e.checked)&&(this._fieldFocusNeeded=!1,this._isInputFieldInGroup(i)&&(i.group.state="expanded"),e.focus())}_handleInputFocus(e){const t=e.target,i=this._getInputFieldFromInput(t);this._activeInputName=i.name,this._isNumberInputField(i)&&(this._activeNumberFieldEdit={fieldName:i.name,input:t,value:t.value})}_isNumberInputField({domain:e,inputType:t="text-box",type:i}){return"number"===i&&"text-box"===t&&(!e||"coded-value"!==e.type)}_handleInputBlur(e){const t=e.target,a=this._getInputFieldFromInput(t);"number"===a.type&&i(this._activeNumberFieldEdit)&&(this._activeNumberFieldEdit.input.value=`${a.value}`,this._activeNumberFieldEdit=null),this._commitInputValue(t),this.scheduleRender()}_commitDateChanges(e,t=!1){const{name:i}=this._getInputFieldFromInput(e);if(!this._dateInputFieldMap.has(i))return;const a=this._dateInputFieldMap.get(i);if(!a||!a.date)return;const n=this._getFieldValueFromDateInput(e),s=this._getFieldValueFromDateInputs(a.date,a.time);this.viewModel.getValue(i)!==s&&(null!==n&&null!==s?this._updateFieldValue(i,s):t&&this._updateFieldValue(i,null))}_commitInputValue(e){const t=this._getInputFieldFromInput(e);i(this._activeNumberFieldEdit)&&this._isNumberInputField(t)&&(this._activeNumberFieldEdit.value=e.value),this._updateFieldValue(t.name,this._parseValue(e))}_handleInputKeyDown(e){const{key:t,altKey:i,ctrlKey:a,metaKey:n}=e,s=this._getInputFieldFromInput(e.target);if("Enter"===t)this._isInputFieldInGroup(s)&&"collapsed"===s.group.state&&(s.group.state="expanded");else{const{type:l}=s.field,r="single"===l||"double"===l;if(("integer"===l||"small-integer"===l||r)&&(!i&&!a&&!n)&&1===t.length){const i=Number(t),a=["-","+"],n=["e","."],s=r?[...a,...n]:a;isNaN(i)&&!s.includes(t)&&e.preventDefault()}}}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._userUpdatedInputFieldNames.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>i(t))));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getInputFieldFromInput(e),i=e.value;if(c(t.fieldElement,"switch")&&"CALCITE-COMBOBOX"!==e.tagName)return e.checked?t.fieldElement.input.onValue:t.fieldElement.input.offValue;if("radio-buttons"===t.inputType&&"radio"===e.type&&!e.checked)return t.value;const{type:a}=t;return"number"===a?i?parseFloat(i):null:i}_handleOptionChange(e){this._commitInputValue(e),this.scheduleRender()}_handleGroupClick(e){const t=e.currentTarget["data-group"],i="expanded"===t.state,a="sequential"===this.groupDisplay,n=`.${d.groupHeader}`;if(!(i&&!e.target.closest(n))){if(this._activeInputName=this._getFocusableInput("forward",t)?.name||"",a){const a=e.target.closest(n);if(i&&!a)return;this.viewModel.inputFields.forEach((e=>{p(e)&&e!==t&&(e.state="collapsed")}))}t.state=i?"collapsed":"expanded",this._fieldFocusNeeded=a,this.scheduleRender()}}_handleSubmit(e){e.preventDefault()}_handleFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_getDefaultLocaleOptions(){return{locale:I(),numberingSystem:w}}_getFieldValueFromDateInputs(e,t){const a=this._getDateTimeFromInput(e),n=this._getDateTimeFromInput(t);if(!a&&!n)return null;const s=this._getInputFieldFromInput(e),l=this._getNumberFieldConstraints(s),r=Date.now(),o=i(l.max)&&l.max<r?l.max:r,u=_.fromMillis(o,this._getDefaultLocaleOptions()),d=a||u,{year:p,month:c,day:m}=d,{hour:h,minute:f,second:g}=n||u,b=d.set({year:p,month:c,day:m,hour:h,minute:f,second:g});return b.isValid?b.toMillis():null}_getDateTimeFromInput(e){if(!e)return null;let t=null;if(V(e)){const i=e.valueAsDate;if(!i||Array.isArray(i))return null;t=_.fromJSDate(i)}else{if(!e.value)return null;t=_.fromFormat(e.value,F,this._getDefaultLocaleOptions())}return t??null}_getFieldValueFromDateInput(e){return this._dateTimeToFieldValue(this._getDateTimeFromInput(e))}_dateTimeToFieldValue(e){return e?.isValid?e.toMillis():null}_dateTimeFromFieldValue(e){return null===e?null:_.fromMillis(e,this._getDefaultLocaleOptions())}_formatValueForDateInputs(e){if(null==e||isNaN(e))return{date:null,time:null};const t=this._dateTimeFromFieldValue(e);return t?{date:t.toJSDate(),time:t.toFormat(F,this._getDefaultLocaleOptions())}:{date:null,time:null}}_valueIsValidContingentValue(e,a){switch(a.objectType){case"any":return!0;case"null":return null==e;case"code":return e===a.codedValue?.code;case"range":return i(e)&&i(a.minValue)&&i(a.maxValue)&&e>=a.minValue&&e<=a.maxValue;default:return t(a.objectType),!1}}};e([s()],D.prototype,"disabled",void 0),e([s()],D.prototype,"feature",null),e([s()],D.prototype,"formTemplate",null),e([s()],D.prototype,"groupDisplay",void 0),e([s()],D.prototype,"headingLevel",void 0),e([s()],D.prototype,"label",null),e([s()],D.prototype,"layer",null),e([s(),g("esri/widgets/FeatureForm/t9n/FeatureForm")],D.prototype,"messages",void 0),e([s(),g("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],D.prototype,"messagesTemplates",void 0),e([s()],D.prototype,"spatialReference",null),e([s()],D.prototype,"strict",null),e([s()],D.prototype,"view",null),e([s(),b(["value-change","submit"])],D.prototype,"viewModel",void 0),D=e([l("esri.widgets.FeatureForm")],D);const x=D;export{x as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{neverReached as t}from"../core/compilerUtils.js";import{isSome as i,isNone as a}from"../core/maybe.js";import{watch as n}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{getDomainRange as r}from"../layers/support/domainUtils.js";import{getFieldRange as o}from"../layers/support/fieldUtils.js";import u from"./Widget.js";import{CSS as d}from"./FeatureForm/css.js";import{isGroupField as p,isFieldElementWithInputType as c}from"./FeatureForm/featureFormUtils.js";import m from"./FeatureForm/FeatureFormViewModel.js";import{Heading as h,incrementHeadingLevel as f}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as g}from"./support/decorators/messageBundle.js";import{vmEvent as b}from"./support/decorators/vmEvent.js";import{tsx as v}from"./support/jsxFactory.js";import{DateTime as _}from"luxon";import{getLocale as I}from"../intl/locale.js";const F="TT",y="data-field-name",w="latn",V=e=>"valueAsDate"in e;let D=class extends u{constructor(e,t){super(e,t),this._dateInputFieldMap=new Map,this._activeInputName="",this._activeNumberFieldEdit=null,this._fieldFocusNeeded=!1,this._fieldToInitialIncompatibleDomainValue=new Map,this._switchFieldsWithInitialIncompatibleValue=new Set,this._userUpdatedInputFieldNames=new Set,this.disabled=!1,this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesTemplates=null,this.viewModel=new m,this._handleInputInput=e=>{this._commitInputValue(e.currentTarget)},this._handleFormKeyDown=this._handleFormKeyDown.bind(this),this._handleInputBlur=this._handleInputBlur.bind(this),this._handleInputFocus=this._handleInputFocus.bind(this),this._handleNumberInputMouseDown=this._handleNumberInputMouseDown.bind(this),this._handleInputKeyDown=this._handleInputKeyDown.bind(this),this._handleOptionChange=this._handleOptionChange.bind(this),this._handleGroupClick=this._handleGroupClick.bind(this),this._handleSubmit=this._handleSubmit.bind(this),this._afterInputCreateOrUpdate=this._afterInputCreateOrUpdate.bind(this),this._afterDateInputCreateOrUpdate=this._afterDateInputCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{const e=this._getFocusableInput("forward");this._activeInputName=e?.name||"",this._userUpdatedInputFieldNames.clear(),this._fieldToInitialIncompatibleDomainValue.clear(),this._switchFieldsWithInitialIncompatibleValue.clear(),this._dateInputFieldMap.clear(),this._fieldFocusNeeded=!0})),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._userUpdatedInputFieldNames.add(e))),this._activeInputName=t,this._fieldFocusNeeded=!0,this.scheduleRender()}}))])}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-combobox.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),import("@esri/calcite-components/dist/components/calcite-input-message.js"),import("@esri/calcite-components/dist/components/calcite-progress.js"),import("@esri/calcite-components/dist/components/calcite-switch.js"),import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),import("@esri/calcite-components/dist/components/calcite-input-time-picker.js")])}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return v("div",{class:this.classes(d.base,d.widget,d.panel)},"ready"===e?this.renderForm():null)}renderForm(){const e=this.viewModel,t=i(e.formTitle)&&v(h,{key:"title",level:this.headingLevel},e.formTitle),a=i(e.formDescription)&&v("p",{class:d.description,key:"description"},e.formDescription),n=t||a?v("div",{class:d.formHeader},t,a):null;return v("form",{class:d.form,novalidate:!0,onsubmit:this._handleSubmit,onkeydown:this._handleFormKeyDown},n,this.renderFields())}renderFields(){const{viewModel:{inputFields:e}}=this;return e.filter((e=>e.visible)).map(((e,t)=>p(e)?this.renderGroup(e,t):this.renderLabeledField(e)))}renderGroup(e,t){const{formTemplate:a,disabled:n}=this,{description:s,inputFields:l,label:r,state:o}=e,u=l.filter((e=>e.visible)),p=this.viewModel.findField(this._activeInputName),c=!(!p||p.group!==e),m=`${this.id}_group_${t}`,g=`${this.id}_group-label_${t}`,b=`${this.id}_group-description_${t}`,_=s?v("p",{class:this.classes(d.groupDescription,d.description),id:b},s):null,I="sequential"===this.groupDisplay,F=I?c:"expanded"===o,y=F?d.collapseIcon:d.expandIcon;return v("fieldset",{"aria-expanded":F.toString(),"aria-labelledby":g,"aria-describedby":s?b:"",class:this.classes(d.group,I?d.groupSequential:null,F?null:d.groupCollapsed,c?d.groupActive:null,n?d.inputDisabled:null),disabled:n,"data-group":e,id:m,key:t,onclick:this._handleGroupClick},v("button",{role:I?"presentation":void 0,class:d.groupHeader,type:"button",tabIndex:I?-1:0},v("div",{class:d.groupTitle},v(h,{class:d.groupLabel,id:g,level:i(a)&&a.title?f(this.headingLevel):this.headingLevel},r),_),I?null:v("span",{class:this.classes(y,d.groupToggleIcon)})),u.map((e=>this.renderLabeledField(e))))}_getFocusableInput(e,t){const i=this.viewModel.allInputFields,a="forward"===e?i:i.slice().reverse();let n;if(t)if(p(t))n=a.indexOf(t.inputFields[0]);else{let i;if(this._isInputFieldInGroup(t)&&"collapsed"===t.group.state){const{inputFields:a}=t.group;i="forward"===e?a[a.length-1]:a[0]}else i=t;n=a.indexOf(i)+1}else n=0;for(let s=n;s<a.length;s++){const e=a[s];if(e.visible)return e}return null}renderLabeledField(e){const{feature:t,label:i,layer:a,type:n}=e;return v("label",{key:`${a.id}-${t.uid}-${e.name}`,class:d.label},[i,"unsupported"!==n?this.renderInputField(e):this.renderUnsupportedField(e),this.renderAuxiliaryText(e)])}renderInputField(e){const{domain:t,name:a,type:n,updating:s,value:l}=e,r=this.getCommonInputProps(e);if("coded-value"===t?.type){if(c(e.fieldElement,"switch")){const{fieldElement:t}=e;if(!(this._switchFieldsWithInitialIncompatibleValue.has(a)||null==l||t.input.onValue!==l&&t.input.offValue!==l))return this.renderSwitchInputField(e,r);this._switchFieldsWithInitialIncompatibleValue.add(a)}return"radio-buttons"===e.inputType?this.renderRadioButtonsInputField(e,t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),r):this.renderSelectInputField(e,this._getFieldValueOptions(a,t),r)}if("datetime-picker"===e.inputType||"date"===n)return this.renderDateInputField(e,r);const o="number"===n?v("input",{type:"number",...r,value:i(this._activeNumberFieldEdit)&&this._activeNumberFieldEdit.fieldName===e.name?this._activeNumberFieldEdit.value:`${r.value}`}):"text-area"===e.inputType?v("textarea",{...r}):v("input",{type:"text",...r});return s?v("div",{class:d.inputFieldWrapper},o,v("div",{class:d.inputFieldLoader},v("calcite-progress",{type:"indeterminate"}))):o}renderDateInputField(e,t){const{includeTime:a,label:n,name:s,valid:l,value:r}=e,{readOnly:o,required:u}=t,{date:p,time:c}=this._formatValueForDateInputs(r),m=i(t.max)?this._formatValueForDateInputs(t.max):void 0,h=i(t.min)?this._formatValueForDateInputs(t.min):void 0,f=m?.date??void 0,g=h?.date??void 0,b={afterCreate:this._afterDateInputCreate,afterUpdate:this._afterDateInputCreateOrUpdate,"aria-invalid":!l,label:n,numberingSystem:w,overlayPositioning:"fixed",readOnly:o,required:u,tabIndex:0,[y]:s};return v("div",{key:`${t.key}-date-time-container`,class:d.dateInputContainer},v("calcite-input-date-picker",{bind:this,...b,class:this.classes(t.class,d.inputDate),"data-date-part":"date",key:`${t.key}-date-input`,valueAsDate:p??void 0,maxAsDate:f,minAsDate:g,onCalciteInputDatePickerChange:e=>this._commitDateChanges(e.target),onblur:e=>this._commitDateChanges(e.target,!0)}),a?v("calcite-input-time-picker",{bind:this,...b,class:this.classes(t.class,d.inputTime),"data-date-part":"time",key:`${t.key}-time-input`,value:c??void 0,step:1,onCalciteInputTimePickerChange:e=>this._commitDateChanges(e.target),onfocus:e=>{e.target.calciteTimePickerEl&&(e.target.calciteTimePickerEl.showSecond=!0)},onblur:e=>this._commitDateChanges(e.target,!0)}):null)}renderUnsupportedField(e){const t=this.getCommonInputProps(e);return v("input",{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,class:this.classes(d.input,d.inputField,d.inputDisabled),onfocus:t.onfocus,readOnly:!0,tabIndex:t.tabIndex,type:"text",value:t.value,[y]:t[y]})}renderSelectInputField(e,t,i){const{value:n}=e,{messages:s,messagesTemplates:l}=this,r=t.map((e=>e.map((e=>v("calcite-combobox-item",{value:`${e.value}`,textLabel:e.name,key:`#${e.value}`,selected:n===e.value}))))),[o,u]=r;this._registerIncompatibleValue(n,t.flat(),e,(e=>{u.unshift(v("calcite-combobox-item",{value:`${e}`,textLabel:`${e}`,key:"incompatible-option",readOnly:!0}))}));const d=u.length>0?[v("calcite-combobox-item-group",{key:"recommended",label:s.recommended},o),v("calcite-combobox-item-group",{key:"other",label:l.other},u)]:o,p=a(e.fieldElement)||c(e.fieldElement,"combo-box")&&e.fieldElement.input.showNoValueOption;if(!e.required&&p){const t="",i=c(e.fieldElement,"combo-box")&&e.fieldElement.input.noValueOptionLabel||this.messages.empty;d.unshift(v("calcite-combobox-item",{value:t,textLabel:this.messages.empty,key:"empty-option"},i))}return v("calcite-combobox",{...i,selectionMode:"single",disabled:i.readOnly,allowCustomValues:!1,onCalciteComboboxChange:e=>this._handleOptionChange(e.target)},d)}_registerIncompatibleValue(e,t,i,a){const n=this._fieldToInitialIncompatibleDomainValue,s=n.has(i.name);(s||null!=e&&""!==e&&!t.some((t=>t.value===e)))&&(s||n.set(i.name,e),a?.(e))}renderRadioButtonsInputField(e,t,i){const{value:n}=e,s=t.map((t=>this.renderRadioButton({key:t.name,label:t.name,name:e.name,value:t.value,selected:t.value===n,props:i})));this._registerIncompatibleValue(n,t,e);const l=a(e.fieldElement)||c(e.fieldElement,"radio-buttons")&&e.fieldElement.input.showNoValueOption;if(!e.required&&l){const t="",a=c(e.fieldElement,"radio-buttons")&&e.fieldElement.input.noValueOptionLabel||this.messages.empty,l=n===t||null===n;s.unshift(this.renderRadioButton({key:"empty-option",label:a,name:e.name,value:t,selected:l,props:i}))}return v("div",{key:`${i.key}-radio`,class:d.inputRadioGroup},s)}renderSwitchInputField(e,t){const{value:i}=e,a=!!c(e.fieldElement,"switch")&&i===e.fieldElement.input.onValue;return v("calcite-switch",{...t,class:d.inputSwitch,onCalciteSwitchChange:e=>this._commitInputValue(e.target),checked:a,disabled:t.readOnly})}renderRadioButton({key:e,name:t,value:i,selected:a,label:n,props:s}){return v("label",{key:e,class:d.inputRadioLabel},v("input",{...s,class:d.inputRadio,name:t,type:"radio",value:i,checked:a,disabled:s.readOnly,onchange:e=>this._commitInputValue(e.target)}),n)}renderAuxiliaryText(e){const t=this._userUpdatedInputFieldNames.has(e.name)&&!e.valid?e.errorMessage:i(this.viewModel.contingencyConstraintViolations.get(e.name))?this.messages.validationErrors.valuesIncompatible:i(e.valueExpressionExecutor)&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return i(t)?v("calcite-input-message",{status:"invalid",icon:!0},t):e.description?v("div",{key:"description",class:d.description},e.description):null}getCommonInputProps(e){const{disabled:t,groupDisplay:a}=this,{editable:n,group:s,hint:l,label:r,maxLength:o,minLength:u,name:p,required:c,type:m,valid:h,value:f}=e,g=this._userUpdatedInputFieldNames.has(p),b=!n||t,v="all"===a&&i(s)&&"collapsed"===s.state;return{afterCreate:this._afterInputCreateOrUpdate,afterUpdate:this._afterInputCreateOrUpdate,"aria-invalid":h?"false":"true",class:this.classes(d.input,d.inputField,b?d.inputDisabled:null,g&&!h?d.inputInvalid:null),key:p,label:r,minlength:u>-1?`${u}`:"",maxlength:o>-1?`${o}`:"",...this._getNumberFieldConstraints(e),readOnly:b,value:null==f?"":`${f}`,[y]:p,onfocus:this._handleInputFocus,oninput:this._handleInputInput,onblur:this._handleInputBlur,onkeydown:this._handleInputKeyDown,onmousedown:"number"===m?this._handleNumberInputMouseDown:null,placeholder:"number"===m||"text"===m?l:"",required:c,tabIndex:v?-1:0}}_isInputFieldInGroup(e){return!p(e)&&i(e.group)}_handleNumberInputMouseDown({target:e}){e.focus(),this.scheduleRender()}_getFieldValueOptions(e,t){const i=t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),a=this.viewModel.fieldsWithContingentValues.has(e)?this._getContingentValueOptions(e):[];if(a.length>0){const e=new Set(a.map((e=>e.value)));return[a,i.filter((t=>!e.has(t.value)))]}return[i,[]]}_getContingentValueOptions(e){const t={};for(const s of this.viewModel.allInputFields){const{name:i,value:n}=s;!a(n)&&i!==e&&this.viewModel.fieldsWithContingentValues.has(i)&&(t[i]=n)}const i=this.viewModel.joinedContingentValues.slice(),n=new Map;for(const s of i){const i=s.values[e];if(a(i)||"code"!==i.objectType&&"null"!==i.objectType)continue;const{code:l,name:r}=i.codedValue&&"null"!==i.objectType?i.codedValue:{code:"",name:this.messages.empty};if(n.has(l))continue;Object.entries(t).every((([e,t])=>!s.values.hasOwnProperty(e)||this._valueIsValidContingentValue(t,s.values[e])))&&n.set(l,{name:r,value:l})}return[...n.values()]}_getInputFieldFromInput(e){return this.viewModel.findField(e.getAttribute(y))}_getNumberFieldConstraints(e){const t=r(e.domain)||o(e.field);return t&&t.max!==Number.MAX_VALUE&&t.min!==Number.MIN_VALUE?t:{min:null,max:null}}async _afterDateInputCreate(e){!V(e)&&i(e.value)&&"setValue"in e&&e.setValue({value:e.value,origin:"external"}),this._afterDateInputCreateOrUpdate(e)}_afterDateInputCreateOrUpdate(e){const{name:t}=this._getInputFieldFromInput(e),a=this._dateInputFieldMap.get(t),n=V(e);i(a)?n?a.date=e:a.time=e:this._dateInputFieldMap.set(t,{[n?"date":"time"]:e}),this._afterInputCreateOrUpdate(e)}_afterInputCreateOrUpdate(e){const{viewModel:t}=this,i=this._getInputFieldFromInput(e),a=t.findField(this._activeInputName),n=this._fieldToInitialIncompatibleDomainValue.get(i.name)===i.value;this._fieldFocusNeeded&&a===i&&("radio-buttons"!==i.inputType||n||e.checked)&&(this._fieldFocusNeeded=!1,this._isInputFieldInGroup(i)&&(i.group.state="expanded"),e.focus())}_handleInputFocus(e){const t=e.target,i=this._getInputFieldFromInput(t);this._activeInputName=i.name,this._isNumberInputField(i)&&(this._activeNumberFieldEdit={fieldName:i.name,input:t,value:t.value})}_isNumberInputField({domain:e,inputType:t="text-box",type:i}){return"number"===i&&"text-box"===t&&(!e||"coded-value"!==e.type)}_handleInputBlur(e){const t=e.target,a=this._getInputFieldFromInput(t);"number"===a.type&&i(this._activeNumberFieldEdit)&&(this._activeNumberFieldEdit.input.value=`${a.value}`,this._activeNumberFieldEdit=null),this._commitInputValue(t),this.scheduleRender()}_commitDateChanges(e,t=!1){const{name:i}=this._getInputFieldFromInput(e);if(!this._dateInputFieldMap.has(i))return;const a=this._dateInputFieldMap.get(i);if(!a||!a.date)return;const n=this._getFieldValueFromDateInput(e),s=this._getFieldValueFromDateInputs(a.date,a.time);this.viewModel.getValue(i)!==s&&(null!==n&&null!==s?this._updateFieldValue(i,s):t&&this._updateFieldValue(i,null))}_commitInputValue(e){const t=this._getInputFieldFromInput(e);i(this._activeNumberFieldEdit)&&this._isNumberInputField(t)&&(this._activeNumberFieldEdit.value=e.value),this._updateFieldValue(t.name,this._parseValue(e))}_handleInputKeyDown(e){const{key:t,altKey:i,ctrlKey:a,metaKey:n}=e,s=this._getInputFieldFromInput(e.target);if("Enter"===t)this._isInputFieldInGroup(s)&&"collapsed"===s.group.state&&(s.group.state="expanded");else{const{type:l}=s.field,r="single"===l||"double"===l;if(("integer"===l||"small-integer"===l||r)&&(!i&&!a&&!n)&&1===t.length){const i=Number(t),a=["-","+"],n=["e","."],s=r?[...a,...n]:a;isNaN(i)&&!s.includes(t)&&e.preventDefault()}}}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._userUpdatedInputFieldNames.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>i(t))));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getInputFieldFromInput(e),i=e.value;if(c(t.fieldElement,"switch")&&"CALCITE-COMBOBOX"!==e.tagName)return e.checked?t.fieldElement.input.onValue:t.fieldElement.input.offValue;if("radio-buttons"===t.inputType&&"radio"===e.type&&!e.checked)return t.value;const{type:a}=t;return"number"===a?i?parseFloat(i):null:i}_handleOptionChange(e){this._commitInputValue(e),this.scheduleRender()}_handleGroupClick(e){const t=e.currentTarget["data-group"],i="expanded"===t.state,a="sequential"===this.groupDisplay,n=`.${d.groupHeader}`;if(!(i&&!e.target.closest(n))){if(this._activeInputName=this._getFocusableInput("forward",t)?.name||"",a){const a=e.target.closest(n);if(i&&!a)return;this.viewModel.inputFields.forEach((e=>{p(e)&&e!==t&&(e.state="collapsed")}))}t.state=i?"collapsed":"expanded",this._fieldFocusNeeded=a,this.scheduleRender()}}_handleSubmit(e){e.preventDefault()}_handleFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_getDefaultLocaleOptions(){return{locale:I(),numberingSystem:w}}_getFieldValueFromDateInputs(e,t){const a=this._getDateTimeFromInput(e),n=this._getDateTimeFromInput(t);if(!a&&!n)return null;const s=this._getInputFieldFromInput(e),l=this._getNumberFieldConstraints(s),r=Date.now(),o=i(l.max)&&l.max<r?l.max:r,u=_.fromMillis(o,this._getDefaultLocaleOptions()),d=a||u,{year:p,month:c,day:m}=d,{hour:h,minute:f,second:g}=n||u,b=d.set({year:p,month:c,day:m,hour:h,minute:f,second:g});return b.isValid?b.toMillis():null}_getDateTimeFromInput(e){if(!e)return null;let t=null;if(V(e)){const i=e.valueAsDate;if(!i||Array.isArray(i))return null;t=_.fromJSDate(i)}else{if(!e.value)return null;t=_.fromFormat(e.value,F,this._getDefaultLocaleOptions())}return t??null}_getFieldValueFromDateInput(e){return this._dateTimeToFieldValue(this._getDateTimeFromInput(e))}_dateTimeToFieldValue(e){return e?.isValid?e.toMillis():null}_dateTimeFromFieldValue(e){return null===e?null:_.fromMillis(e,this._getDefaultLocaleOptions())}_formatValueForDateInputs(e){if(null==e||isNaN(e))return{date:null,time:null};const t=this._dateTimeFromFieldValue(e);return t?{date:t.toJSDate(),time:t.toFormat(F,this._getDefaultLocaleOptions())}:{date:null,time:null}}_valueIsValidContingentValue(e,a){switch(a.objectType){case"any":return!0;case"null":return null==e;case"code":return e===a.codedValue?.code;case"range":return i(e)&&i(a.minValue)&&i(a.maxValue)&&e>=a.minValue&&e<=a.maxValue;default:return t(a.objectType),!1}}};e([s()],D.prototype,"disabled",void 0),e([s()],D.prototype,"feature",null),e([s()],D.prototype,"formTemplate",null),e([s()],D.prototype,"groupDisplay",void 0),e([s()],D.prototype,"headingLevel",void 0),e([s()],D.prototype,"label",null),e([s()],D.prototype,"layer",null),e([s(),g("esri/widgets/FeatureForm/t9n/FeatureForm")],D.prototype,"messages",void 0),e([s(),g("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],D.prototype,"messagesTemplates",void 0),e([s()],D.prototype,"spatialReference",null),e([s()],D.prototype,"strict",null),e([s()],D.prototype,"view",null),e([s(),b(["value-change","submit"])],D.prototype,"viewModel",void 0),D=e([l("esri.widgets.FeatureForm")],D);const x=D;export{x as default};