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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +2 -2
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{a8565d1c676f3bfbcebb.js → 002fe1ec63ea33e6972d.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{0610691a0c0d9fbbd6d2.js → 013de5c2955801b329b3.js} +1 -1
  5. package/assets/esri/core/workers/chunks/07163dcbb871f927a580.js +1 -0
  6. package/assets/esri/core/workers/chunks/0e46687004392c493c06.js +1 -0
  7. package/assets/esri/core/workers/chunks/0e65e00173b66c7fec2e.js +1 -0
  8. package/assets/esri/core/workers/chunks/1aa8dd317ecd3c41e0ea.js +1 -0
  9. package/assets/esri/core/workers/chunks/21328f3dd26abe84a10d.js +1 -0
  10. package/assets/esri/core/workers/chunks/28c67c98039503b62e6e.js +1 -0
  11. package/assets/esri/core/workers/chunks/2faa8f08f2fdaac3f4af.js +1 -0
  12. package/assets/esri/core/workers/chunks/{0407bf97ad621c89a734.js → 3160af63b860b52db389.js} +1 -1
  13. package/assets/esri/core/workers/chunks/3767b9e7660873b018c2.js +1 -0
  14. package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +1 -0
  15. package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +1 -0
  16. package/assets/esri/core/workers/chunks/471f6eba213412b82840.js +1 -0
  17. package/assets/esri/core/workers/chunks/4a4f14a3d8da270059c4.js +1 -0
  18. package/assets/esri/core/workers/chunks/{3e239bfad611985e50fb.js → 50f910797c17c3028521.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{f339db2b599fa9585283.js → 5e6471dd2a08e66b47d0.js} +79 -81
  20. package/assets/esri/core/workers/chunks/642c5a93c0a454bdd115.js +1 -0
  21. package/assets/esri/core/workers/chunks/{14145959a3dab1437818.js → 6627f1bc9ee6b620e3aa.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{170bdbdb4e21bf91a17f.js → 6eaa7a51efde2dd4a5a4.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{d8bd3f498b3fa8153404.js → 6f510f28526c73ab453c.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{2bdc63395c7466ce1641.js → 7053c2f5a958d4c8629b.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{4c35c663528f710e8c78.js → 79cb672c85ea29e8484a.js} +1 -1
  26. package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +1 -0
  27. package/assets/esri/core/workers/chunks/83e3d104886b48f00397.js +1 -0
  28. package/assets/esri/core/workers/chunks/89001ee8d3f69fa03cc1.js +1 -0
  29. package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +1 -0
  30. package/assets/esri/core/workers/chunks/9472184ef1432fc55d6b.js +1 -0
  31. package/assets/esri/core/workers/chunks/{3c5a64a545272f148e93.js → 9621b7d8d951aa881686.js} +1 -1
  32. package/assets/esri/core/workers/chunks/a6ddf80eb324c35076e1.js +1 -0
  33. package/assets/esri/core/workers/chunks/a80a6267d88246ede5d3.js +1 -0
  34. package/assets/esri/core/workers/chunks/{b6e173eddaad4244cb5f.js → b31974524932e638df8c.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{f505ebd4bd3bfb6c790d.js → b6a55fdfe16795ebf02c.js} +1 -1
  36. package/assets/esri/core/workers/chunks/bf9e1fde9f6b2b4f10c0.js +1 -0
  37. package/assets/esri/core/workers/chunks/cfa3b2b1e184681e9af4.js +1 -0
  38. package/assets/esri/core/workers/chunks/{92e7f224a80195e606d6.js → d4ba894a2583f3930a4f.js} +1 -1
  39. package/assets/esri/core/workers/chunks/d5dfd3d693d5e393a542.js +1 -0
  40. package/assets/esri/core/workers/chunks/dabd889e064c4e7807fa.js +1 -0
  41. package/assets/esri/core/workers/chunks/{74fd2059ddda9083cbcc.js → dc6c97a43d642eeaf477.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{2154d395f405be3cd3ba.js → eca0c3d57b3a1e3a14ee.js} +1 -1
  43. package/assets/esri/core/workers/chunks/f35895e03c036d67b3ed.js +1 -0
  44. package/assets/esri/core/workers/chunks/f36697f6aac782007d1a.js +1 -0
  45. package/assets/esri/core/workers/chunks/f52054f27619a98b7bb7.js +1 -0
  46. package/assets/esri/core/workers/chunks/{c6efe2e04ea6a55bb6e3.js → f6e68befe2812b90b40d.js} +1 -1
  47. package/assets/esri/core/workers/chunks/fb7fe307a583b6a22218.js +1 -0
  48. package/assets/esri/core/workers/chunks/fbd3c78ee8e2219a6c7a.js +1 -0
  49. package/assets/esri/core/workers/chunks/ff42585e1b1d0c5497af.js +1 -0
  50. package/assets/esri/images/portal/livestreamvideolayer16.png +0 -0
  51. package/assets/esri/images/portal/{mediaservice16.png → videolayer16.png} +0 -0
  52. package/assets/esri/themes/base/widgets/_Feature.scss +4 -0
  53. package/assets/esri/themes/base/widgets/_FeatureContent.scss +9 -2
  54. package/assets/esri/themes/base/widgets/_FeatureForm.scss +19 -2
  55. package/assets/esri/themes/base/widgets/_ScaleRangeSlider.scss +1 -0
  56. package/assets/esri/themes/dark/main.css +1 -1
  57. package/assets/esri/themes/light/main.css +1 -1
  58. package/assets/esri/themes/light/view.css +1 -1
  59. package/chunks/DefaultMaterial.glsl.js +3 -2
  60. package/chunks/ShadowCastAccumulate.glsl.js +1 -1
  61. package/core/timeUtils.js +1 -1
  62. package/geometry/Mesh.js +1 -1
  63. package/geometry/support/DoubleArray.js +1 -1
  64. package/geometry/support/meshVertexSpaceUtils.js +5 -0
  65. package/interfaces.d.ts +263 -31
  66. package/kernel.js +1 -1
  67. package/layers/VideoLayer.js +1 -1
  68. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  69. package/layers/graphics/controllers/StreamController.js +1 -1
  70. package/layers/graphics/data/QueryEngine.js +1 -1
  71. package/layers/graphics/data/attributeSupport.js +1 -1
  72. package/layers/graphics/editingSupport.js +1 -1
  73. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  74. package/layers/support/editableLayers.js +1 -1
  75. package/layers/support/layerUtils.js +1 -1
  76. package/layers/video/VideoController.js +1 -1
  77. package/layers/video/videoUtils.js +5 -0
  78. package/package.json +1 -1
  79. package/portal/PortalItem.js +1 -1
  80. package/request.js +1 -1
  81. package/rest/support/meshFeatureSet.js +1 -1
  82. package/smartMapping/symbology/flow.js +1 -1
  83. package/statistics/utils.js +1 -1
  84. package/support/requestUtils.js +1 -1
  85. package/support/revision.js +1 -1
  86. package/symbols/cim/CIMSymbolHelper.js +1 -1
  87. package/views/2d/layers/StreamLayerView2D.js +1 -1
  88. package/views/2d/layers/features/sources/StreamSource.js +1 -1
  89. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  90. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  91. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  92. package/views/3d/layers/I3SMeshView3D.js +1 -1
  93. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  94. package/views/3d/layers/II3SMeshView3D.js +1 -1
  95. package/views/3d/layers/SceneLayerView3D.js +1 -1
  96. package/views/3d/layers/SceneLayerWorker.js +1 -1
  97. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  98. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  99. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  100. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  101. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  102. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  103. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  104. package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
  105. package/views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js +3 -9
  106. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +12 -9
  107. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js +10 -10
  108. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
  109. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterDistortion.glsl.js +2 -2
  110. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +8 -8
  111. package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
  112. package/views/3d/webgl-engine/lib/ShadowHighlight.js +1 -1
  113. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  114. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  115. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  116. package/views/3d/webgl-engine/materials/pbrUtils.js +1 -1
  117. package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +1 -1
  118. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  119. package/views/3d/webgl-engine/shaders/ShadowHighlightTechnique.js +1 -1
  120. package/views/draw/DrawGraphicTool.js +1 -1
  121. package/views/layers/GroupLayerView.js +1 -1
  122. package/webmap/initialViewPropertiesUtils.js +1 -1
  123. package/widgets/Daylight/DaylightViewModel.js +1 -1
  124. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  125. package/widgets/Editor/CreateWorkflow.js +1 -1
  126. package/widgets/Editor/EditorViewModel.js +1 -1
  127. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  128. package/widgets/Editor/UpdateWorkflow.js +1 -1
  129. package/widgets/Editor/UpdateWorkflowData.js +1 -1
  130. package/widgets/Editor/Workflow.js +1 -1
  131. package/widgets/Editor/workflowUtils.js +1 -1
  132. package/widgets/Editor.js +1 -1
  133. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  134. package/widgets/Feature/FeatureRelationship.js +1 -1
  135. package/widgets/Feature/support/featureUtils.js +1 -1
  136. package/widgets/FeatureForm/EditableInput.d.ts +2 -2
  137. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  138. package/widgets/FeatureForm/RelationshipInput.js +1 -1
  139. package/widgets/FeatureForm/css.js +1 -1
  140. package/widgets/FeatureForm.js +1 -1
  141. package/widgets/FeatureTable/FieldColumn.js +1 -1
  142. package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
  143. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  144. package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
  145. package/widgets/UtilityNetworkTrace/support/ResultAreaHandler.js +1 -1
  146. package/widgets/UtilityNetworkTrace.js +1 -1
  147. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.d.ts +4 -0
  148. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  149. package/widgets/UtilityNetworkValidateTopology.d.ts +4 -0
  150. package/widgets/UtilityNetworkValidateTopology.js +1 -1
  151. package/widgets/ValuePicker/ValuePickerBaseComponent.js +1 -1
  152. package/widgets/ValuePicker.js +1 -1
  153. package/widgets/support/geolocationUtils.js +1 -1
  154. package/assets/esri/core/workers/chunks/07651ef8348f702d59ac.js +0 -1
  155. package/assets/esri/core/workers/chunks/0a02ac5628d1739372c6.js +0 -1
  156. package/assets/esri/core/workers/chunks/0fcb8d408696075338e2.js +0 -1
  157. package/assets/esri/core/workers/chunks/16e459b16bdd6e1a821b.js +0 -1
  158. package/assets/esri/core/workers/chunks/1b8074269800b384ecf6.js +0 -1
  159. package/assets/esri/core/workers/chunks/39714837f9d3708e3806.js +0 -1
  160. package/assets/esri/core/workers/chunks/3ba2fcb9110230f8790c.js +0 -1
  161. package/assets/esri/core/workers/chunks/474d9b334812533bab36.js +0 -1
  162. package/assets/esri/core/workers/chunks/5576858f56314afcb4d5.js +0 -1
  163. package/assets/esri/core/workers/chunks/5706edf45402dff279a6.js +0 -1
  164. package/assets/esri/core/workers/chunks/659b7bad7281c0e2aed3.js +0 -1
  165. package/assets/esri/core/workers/chunks/785a6c925f29bc962992.js +0 -1
  166. package/assets/esri/core/workers/chunks/90da1ed112b82712d0ef.js +0 -1
  167. package/assets/esri/core/workers/chunks/9326120c750799eb2d28.js +0 -1
  168. package/assets/esri/core/workers/chunks/99e0cec47e3ef72c1de4.js +0 -1
  169. package/assets/esri/core/workers/chunks/9c0e1e87790424f42d7e.js +0 -1
  170. package/assets/esri/core/workers/chunks/9e66af3b1c70cf25fb32.js +0 -1
  171. package/assets/esri/core/workers/chunks/a1c31bb8c12831539328.js +0 -1
  172. package/assets/esri/core/workers/chunks/b0cda39b53ecd6c44cd0.js +0 -1
  173. package/assets/esri/core/workers/chunks/b5fc6f2044ed047c5afd.js +0 -1
  174. package/assets/esri/core/workers/chunks/c08e03165043df67c11b.js +0 -1
  175. package/assets/esri/core/workers/chunks/c26148d4bfab3b3dfab2.js +0 -1
  176. package/assets/esri/core/workers/chunks/d6b6bb8aecc85d2a3f6b.js +0 -1
  177. package/assets/esri/core/workers/chunks/eeaf8010e38b65a101ac.js +0 -1
  178. package/assets/esri/core/workers/chunks/f235392c56063fbf89c6.js +0 -1
  179. package/assets/esri/core/workers/chunks/fdd0d3616c97e408b104.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import{ClonableMixin as l}from"../../../core/Clonable.js";import a from"../../../core/Collection.js";import{HandleOwnerMixin as s}from"../../../core/HandleOwner.js";import{IdentifiableMixin as i}from"../../../core/Identifiable.js";import{ignoreAbortErrors as n}from"../../../core/promiseUtils.js";import{watch as u,initial as d}from"../../../core/reactiveUtils.js";import{throttle as y}from"../../../core/throttle.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as C,findRelatedLayer as g}from"../support/featureUtils.js";import{parseFormTemplateString as F,getFieldsInTitleAndDesc as _}from"../../FeatureForm/featureFormUtils.js";const b=100;let m=class extends(l(i(s(r)))){constructor(e){super(e),this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await n(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await n(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null)},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await n(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryThrottled=y(this._queryController,b,this),this._queryFeatureCountThrottled=y(this._queryFeatureCountController,b,this),this._queryPageThrottled=y(this._queryPageController,b,this),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.removeAll(),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal})))},this.handles.add([u((()=>[this.displayCount,this.graphic,this.layer,this.map,this.orderByFieldsFixedCasing,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount]),(()=>this._queryThrottled()),d),u((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageThrottled())),u((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery]),(()=>this._queryFeatureCountThrottled()))])}initialize(){this.addHandles(this._queryThrottled)}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.removeAll(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=C(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&"number"==typeof this.relationshipId&&"number"==typeof this.objectId&&e?.supportsCount&&e?.supportsPagination)}get itemDescriptionFieldName(){return this.orderByFieldsFixedCasing[0]?.field||null}set displayCount(e){const t=0,r=10;this._set("displayCount",Math.min(Math.max(e,t),r))}get displayCount(){return this._get("displayCount")}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get relatedFeatures(){return this._get("relatedFeatures")||new a}get relatedFeatureInfos(){const{itemDescriptionFieldName:e,relatedFeatures:t,relatedLayer:r}=this;if(!t.length||!r)return[];const o=r&&"formTemplate"in r&&r.formTemplate,l=o&&o?.title||void 0;return t.map((t=>({feature:t,description:e?t.getAttribute(e):void 0,title:l?F(l,t.attributes,r.fieldsIndex):void 0}))).toArray()}get relatedLayer(){const{layer:e,map:t,relationship:r}=this;return e?.loaded&&t&&r?g(t,e,r)??null:null}get relationship(){const{relationshipId:e,layer:t}=this;return"number"==typeof e?t?.relationships?.find((({id:t})=>t===e))??null:null}get relatedFeatureViewModels(){return this._get("relatedFeatureViewModels")||new a}get state(){const{_queryAbortController:e,_queryFeatureCountAbortController:t,_queryPageAbortController:r,canQuery:o}=this;return t?"loading":e||r?"querying":o?"ready":"disabled"}getRelatedFeatureByObjectId(e){return this.relatedFeatures.find((t=>t.getObjectId()===e))}_destroyRelatedFeatureViewModels(){this.relatedFeatureViewModels?.forEach((e=>!e.destroyed&&e.destroy())),this.relatedFeatureViewModels.removeAll()}async _queryFeatureCount(){const{layer:e,relatedLayer:t,relationshipId:r,objectId:o,_queryFeatureCountAbortController:l,canQuery:a,supportsCacheHint:s}=this;if(await(e?.load()),await(t?.load()),!a||!e||!t)return void this._set("featureCount",0);const i=t.createQuery(),n=new c({cacheHint:s,relationshipId:r,returnGeometry:!1,objectIds:[o],where:i.where??void 0}),u=await e.queryRelatedFeaturesCount(n,{signal:l?.signal});this._set("featureCount",u[o]||0)}_sliceFeatures(e){const{showAllEnabled:t,displayCount:r}=this;return t?e:r?e.slice(0,r):[]}async _queryPage(){const{relatedFeatures:e,featurePage:t,showAllEnabled:r,_queryPageAbortController:o}=this;!r||t<2||e.addMany(await this._queryRelatedFeatures({signal:o?.signal}))}async _queryRelatedFeatures(e){const{orderByFieldsFixedCasing:t,showAllEnabled:r,featuresPerPage:l,displayCount:a,layer:s,relationshipId:i,featurePage:n,featureCount:u,relatedLayer:d,supportsCacheHint:y}=this,{canQuery:h,objectId:p}=this;if(!h||!s||!d)return[];const C=r?((n-1)*l+u)%u:0,g=r?l:a,F=d.objectIdField,b=[...t.map((e=>e.field)),..._(d),F].filter(o),m=t.map((e=>`${e.field} ${e.order}`)),f=d.createQuery(),q=new c({orderByFields:m,start:C,num:g,outFields:b,cacheHint:y,relationshipId:i,returnGeometry:!1,objectIds:[p],where:f.where??void 0}),A=await s.queryRelatedFeatures(q,{signal:e?.signal}),w=A[p]?.features||[];return w.forEach((e=>{e.sourceLayer=d,e.layer=d})),w}};e([h()],m.prototype,"_queryAbortController",void 0),e([h()],m.prototype,"_queryPageAbortController",void 0),e([h()],m.prototype,"_queryFeatureCountAbortController",void 0),e([h({value:1})],m.prototype,"featurePage",null),e([h()],m.prototype,"featuresPerPage",void 0),e([h({readOnly:!0})],m.prototype,"orderByFieldsFixedCasing",null),e([h({readOnly:!0})],m.prototype,"supportsCacheHint",null),e([h({readOnly:!0})],m.prototype,"canQuery",null),e([h()],m.prototype,"description",void 0),e([h({readOnly:!0})],m.prototype,"itemDescriptionFieldName",null),e([h({value:3})],m.prototype,"displayCount",null),e([h({type:t})],m.prototype,"graphic",void 0),e([h()],m.prototype,"layer",void 0),e([h()],m.prototype,"map",void 0),e([h({readOnly:!0})],m.prototype,"objectId",null),e([h({readOnly:!0})],m.prototype,"objectIdField",null),e([h()],m.prototype,"orderByFields",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatures",null),e([h({readOnly:!0})],m.prototype,"relatedFeatureInfos",null),e([h({readOnly:!0})],m.prototype,"relatedLayer",null),e([h({readOnly:!0})],m.prototype,"relationship",null),e([h()],m.prototype,"featureCount",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatureViewModels",null),e([h()],m.prototype,"relationshipId",void 0),e([h()],m.prototype,"showAllEnabled",void 0),e([h()],m.prototype,"state",null),e([h()],m.prototype,"title",void 0),e([h()],m.prototype,"getRelatedFeatureByObjectId",null),m=e([p("esri.widgets.Feature.FeatureRelationship.FeatureRelationshipViewModel")],m);const f=m;export{f as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{isSome as o}from"../../../core/arrayUtils.js";import{ClonableMixin as l}from"../../../core/Clonable.js";import a from"../../../core/Collection.js";import{HandleOwnerMixin as s}from"../../../core/HandleOwner.js";import{IdentifiableMixin as i}from"../../../core/Identifiable.js";import{ignoreAbortErrors as n,debounce as u}from"../../../core/promiseUtils.js";import{watch as d,initial as y}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import c from"../../../rest/support/RelationshipQuery.js";import{getFixedFieldName as C,findRelatedLayer as b}from"../support/featureUtils.js";import{parseFormTemplateString as g,getFieldsInTitleAndDesc as F}from"../../FeatureForm/featureFormUtils.js";const _=100;let m=class extends(l(i(s(r)))){constructor(e){super(e),this._loaded=!1,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=10,this.description=null,this.graphic=null,this.layer=null,this.map=null,this.orderByFields=null,this.featureCount=0,this.relationshipId=null,this.showAllEnabled=!1,this.title=null,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await n(this._query()),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async()=>{this._loaded=!1,this._cancelQueryFeatureCount();const e=new AbortController;this._queryFeatureCountAbortController=e,await n(this._queryFeatureCount()),this._queryFeatureCountAbortController===e&&(this._queryFeatureCountAbortController=null),this._loaded=!0},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await n(this._queryPage()),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=u(this._queryController,_),this._queryFeatureCountDebounced=u(this._queryFeatureCountController,_),this._queryPageDebounced=u(this._queryPageController,_),this._query=async()=>{const{_queryAbortController:e,relatedFeatures:t}=this;this.featureCount&&(this._destroyRelatedFeatureViewModels(),this.featurePage=1,t.removeAll(),this.destroyed||t.addMany(this._sliceFeatures(await this._queryRelatedFeatures({signal:e?.signal}))))},this.handles.add([d((()=>[this.displayCount,this.graphic,this.layer,this.map,this.orderByFieldsFixedCasing,this.relationshipId,this.featuresPerPage,this.showAllEnabled,this.canQuery,this.featureCount]),(()=>this._queryDebounced()),y),d((()=>[this.featurePage,this.showAllEnabled]),(()=>this._queryPageDebounced())),d((()=>[this.layer,this.relationshipId,this.objectId,this.canQuery]),(()=>this._queryFeatureCountDebounced()))])}destroy(){this._destroyRelatedFeatureViewModels(),this.relatedFeatures.removeAll(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,l=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),l))}get featurePage(){return this._get("featurePage")}get orderByFieldsFixedCasing(){const{orderByFields:e,relatedLayer:t}=this;return e&&t?.loaded?e.map((e=>{const r=e.clone();return r.field=C(e.field,t),r})):e??[]}get supportsCacheHint(){return!!this.layer?.capabilities?.queryRelated?.supportsCacheHint}get canLoad(){return!!this.map&&"number"==typeof this.relationshipId&&"number"==typeof this.objectId}get canQuery(){const e=this.layer?.capabilities?.queryRelated;return!!(this.relatedLayer&&this.relationship&&"number"==typeof this.relationshipId&&"number"==typeof this.objectId&&e?.supportsCount&&e?.supportsPagination)}get itemDescriptionFieldName(){return this.orderByFieldsFixedCasing[0]?.field||null}set displayCount(e){const t=0,r=10;this._set("displayCount",Math.min(Math.max(e,t),r))}get displayCount(){return this._get("displayCount")}get objectId(){return(this.objectIdField&&this.graphic?.attributes?.[this.objectIdField])??null}get objectIdField(){return this.layer?.objectIdField||null}get relatedFeatures(){return this._get("relatedFeatures")||new a}get relatedFeatureInfos(){const{itemDescriptionFieldName:e,relatedFeatures:t,relatedLayer:r}=this;if(!t.length||!r)return[];const o=r&&"formTemplate"in r&&r.formTemplate,l=o&&o?.title||void 0;return t.map((t=>({feature:t,description:e?t.getAttribute(e):void 0,title:l?g(l,t.attributes,r.fieldsIndex):void 0}))).toArray()}get relatedLayer(){const{layer:e,map:t,relationship:r}=this;return e?.loaded&&t&&r?b(t,e,r)??null:null}get relationship(){const{relationshipId:e,layer:t}=this;return"number"==typeof e?t?.relationships?.find((({id:t})=>t===e))??null:null}get relatedFeatureViewModels(){return this._get("relatedFeatureViewModels")||new a}get state(){const{_queryAbortController:e,_queryFeatureCountAbortController:t,_queryPageAbortController:r,canQuery:o,_loaded:l,canLoad:a}=this;return t||a&&!l?"loading":e||r?"querying":o?"ready":"disabled"}getRelatedFeatureByObjectId(e){return this.relatedFeatures.find((t=>t.getObjectId()===e))}_destroyRelatedFeatureViewModels(){this.relatedFeatureViewModels?.forEach((e=>!e.destroyed&&e.destroy())),this.relatedFeatureViewModels.removeAll()}async _queryFeatureCount(){const{layer:e,relatedLayer:t,relationshipId:r,objectId:o,_queryFeatureCountAbortController:l,canQuery:a,supportsCacheHint:s}=this;if(await(e?.load()),await(t?.load()),!a||!e||!t)return void this._set("featureCount",0);const i=t.createQuery(),n=new c({cacheHint:s,relationshipId:r,returnGeometry:!1,objectIds:[o],where:i.where??void 0}),u=await e.queryRelatedFeaturesCount(n,{signal:l?.signal});this._set("featureCount",u[o]||0)}_sliceFeatures(e){const{showAllEnabled:t,displayCount:r}=this;return t?e:r?e.slice(0,r):[]}async _queryPage(){const{relatedFeatures:e,featurePage:t,showAllEnabled:r,_queryPageAbortController:o,featureCount:l}=this;!r||t<2||!l||e.addMany(await this._queryRelatedFeatures({signal:o?.signal}))}async _queryRelatedFeatures(e){const{orderByFieldsFixedCasing:t,showAllEnabled:r,featuresPerPage:l,displayCount:a,layer:s,relationshipId:i,featurePage:n,featureCount:u,relatedLayer:d,supportsCacheHint:y}=this,{canQuery:h,objectId:p}=this;if(!h||!s||!d)return[];const C=r?((n-1)*l+u)%u:0,b=r?l:a,g=d.objectIdField,_=[...t.map((e=>e.field)),...F(d),g].filter(o),m=t.map((e=>`${e.field} ${e.order}`)),f=d.createQuery(),q=new c({orderByFields:m,start:C,num:b,outFields:_,cacheHint:y,relationshipId:i,returnGeometry:!1,objectIds:[p],where:f.where??void 0}),A=await s.queryRelatedFeatures(q,{signal:e?.signal}),w=A[p]?.features||[];return w.forEach((e=>{e.sourceLayer=d,e.layer=d})),w}};e([h()],m.prototype,"_loaded",void 0),e([h()],m.prototype,"_queryAbortController",void 0),e([h()],m.prototype,"_queryPageAbortController",void 0),e([h()],m.prototype,"_queryFeatureCountAbortController",void 0),e([h({value:1})],m.prototype,"featurePage",null),e([h()],m.prototype,"featuresPerPage",void 0),e([h({readOnly:!0})],m.prototype,"orderByFieldsFixedCasing",null),e([h({readOnly:!0})],m.prototype,"supportsCacheHint",null),e([h({readOnly:!0})],m.prototype,"canLoad",null),e([h({readOnly:!0})],m.prototype,"canQuery",null),e([h()],m.prototype,"description",void 0),e([h({readOnly:!0})],m.prototype,"itemDescriptionFieldName",null),e([h({value:3})],m.prototype,"displayCount",null),e([h({type:t})],m.prototype,"graphic",void 0),e([h()],m.prototype,"layer",void 0),e([h()],m.prototype,"map",void 0),e([h({readOnly:!0})],m.prototype,"objectId",null),e([h({readOnly:!0})],m.prototype,"objectIdField",null),e([h()],m.prototype,"orderByFields",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatures",null),e([h({readOnly:!0})],m.prototype,"relatedFeatureInfos",null),e([h({readOnly:!0})],m.prototype,"relatedLayer",null),e([h({readOnly:!0})],m.prototype,"relationship",null),e([h()],m.prototype,"featureCount",void 0),e([h({readOnly:!0})],m.prototype,"relatedFeatureViewModels",null),e([h()],m.prototype,"relationshipId",void 0),e([h()],m.prototype,"showAllEnabled",void 0),e([h()],m.prototype,"state",null),e([h()],m.prototype,"title",void 0),e([h()],m.prototype,"getRelatedFeatureByObjectId",null),m=e([p("esri.widgets.Feature.FeatureRelationship.FeatureRelationshipViewModel")],m);const f=m;export{f as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{destroyMaybe as t}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{watch as r,initial as i,on as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import{cast as a}from"../../core/accessorSupport/decorators/cast.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import d from"../Widget.js";import c from"./FeatureRelationship/FeatureRelationshipViewModel.js";import u from"./support/FeatureElementInfo.js";import{loadCalciteComponents as h}from"../support/componentsUtils.js";import{isRTL as p}from"../support/widgetUtils.js";import{messageBundle as m}from"../support/decorators/messageBundle.js";import{tsx as v}from"../support/jsxFactory.js";import{substitute as g}from"../../intl/substitute.js";const w="esri-feature",b=`${w}-relationship`,f={base:b,esriWidget:"esri-widget",listContainer:`${b}__list`,listContainerQuerying:`${b}__list--querying`,featureObserver:`${w}__feature-observer`,stickySpinnerContainer:`${w}__sticky-loading-container`,loadingSpinnerContainer:`${w}__loading-container`,spinner:`${w}__loading-spinner`,iconLoading:"esri-icon-loading-indicator esri-rotating"},y={title:!0,description:!0};let F=class extends d{constructor(e,t){super(e,t),this._featureElementInfo=null,this._relatedFeatureIntersectionObserverNode=null,this._relatedFeatureIntersectionObserver=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this.headingLevel=2,this.viewModel=new c,this.messages=null,this.messagesCommon=null,this.visibleElements={...y},this._increaseFeaturePage=()=>{const{state:e,showAllEnabled:t,relatedFeatures:s,featuresPerPage:r,featurePage:i}=this.viewModel;"ready"===e&&t&&s.length>=r*i&&this.viewModel.featurePage++}}initialize(){this._featureElementInfo=new u,this.addHandles([r((()=>[this.viewModel.description,this.viewModel.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),i),r((()=>[this.viewModel.state,this.viewModel.showAllEnabled,this._relatedFeatureIntersectionObserverNode]),(()=>this._handleRelatedFeatureObserverChange())),o((()=>this.viewModel.relatedFeatureViewModels),"change",(()=>this._setupRelatedFeatureViewModels()))])}loadDependencies(){return h({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js")})}destroy(){this._unobserveRelatedFeatureObserver(),this._featureElementInfo=t(this._featureElementInfo)}get displayShowAllButton(){const{showAllEnabled:e,featureCount:t,displayCount:s,state:r}=this.viewModel;return!e&&!!t&&"ready"===r&&(t>s||0===s)}get displayListItems(){return this.displayShowAllButton||this.viewModel.relatedFeatureViewModels.length>0}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get featureCountDescription(){const{messages:e}=this,{featureCount:t}=this.viewModel;return g(e?.numberRecords,{number:t})}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}castVisibleElements(e){return{...y,...e}}renderStickyLoading(){return"querying"===this.viewModel.state?v("div",{key:"sticky-loader",class:f.stickySpinnerContainer},this.renderLoadingIcon()):null}renderLoadingIcon(){return v("span",{class:this.classes(f.iconLoading,f.spinner)})}renderLoading(){return v("div",{key:"loading-container",class:f.loadingSpinnerContainer},this.renderLoadingIcon())}renderShowAllIconNode(){return v("calcite-icon",{scale:"s",icon:"list",slot:"content-end"})}renderChevronIconNode(){const e=p(this.container)?"chevron-left":"chevron-right";return v("calcite-icon",{scale:"s",icon:e,slot:"content-end"})}renderRelatedFeature(e){const{itemDescriptionFieldName:t}=this.viewModel,s=e.title;e.description=t&&e.formattedAttributes?.global[t];const r="loading"===e.state;return v("calcite-list-item",{key:e.uid,label:r?`${this.messagesCommon?.loading}…`:s,description:r?"…":e.description??"",onCalciteListItemSelect:()=>this.emit("select-record",{featureViewModel:e})},this.renderChevronIconNode())}renderShowAllListItem(){return this.displayShowAllButton?v("calcite-list-item",{key:"show-all-item",label:this.messages?.showAll,description:this.featureCountDescription,onCalciteListItemSelect:()=>this.emit("show-all-records")},this.renderShowAllIconNode()):null}renderNoRelatedFeaturesMessage(){return v("calcite-notice",{key:"no-related-features-message",icon:"information",open:!0,kind:"brand",scale:"s",width:"full"},v("div",{slot:"message"},this.messages?.noRelatedFeatures))}renderFeatureObserver(){return v("div",{key:"feature-observer",class:f.featureObserver,bind:this,afterCreate:this._relatedFeatureIntersectionObserverCreated})}renderList(){const{relatedFeatureViewModels:e}=this.viewModel;return v("calcite-list",null,e.toArray().map((e=>this.renderRelatedFeature(e))),this.renderShowAllListItem())}renderRelatedFeatures(){const{displayListItems:e}=this,{state:t}=this.viewModel;return v("div",{key:"list-container",class:this.classes(f.listContainer,{[f.listContainerQuerying]:"querying"===t})},e?this.renderList():"ready"===t?this.renderNoRelatedFeaturesMessage():null,this.renderStickyLoading(),this.renderFeatureObserver())}renderRelationshipNotFound(){return v("calcite-notice",{key:"relationship-not-found",icon:"exclamation-mark-triangle",open:!0,kind:"danger",scale:"s",width:"full"},v("div",{slot:"message"},this.messages?.relationshipNotFound))}render(){const{state:e}=this.viewModel;return v("div",{class:this.classes(f.base,f.esriWidget)},this._featureElementInfo?.render(),"loading"===e?this.renderLoading():"disabled"===e?this.renderRelationshipNotFound():this.renderRelatedFeatures())}_setupRelatedFeatureViewModels(){const{relatedFeatureViewModels:e}=this.viewModel,t="related-feature-viewmodels";this.removeHandles(t),e?.forEach((e=>{this.addHandles(r((()=>[e.title,e.state]),(()=>this.scheduleRender()),i),t)})),this.scheduleRender()}_setupFeatureElementInfo(){const{headingLevel:e,visibleElements:t}=this,s=t.description&&this.description,r=t.title&&this.title;this._featureElementInfo?.set({description:s,title:r,headingLevel:e})}async _handleRelatedFeatureObserverChange(){this._unobserveRelatedFeatureObserver();const{state:e,showAllEnabled:t}=this.viewModel;await s(0),this._relatedFeatureIntersectionObserverNode&&"ready"===e&&t&&this._relatedFeatureIntersectionObserver.observe(this._relatedFeatureIntersectionObserverNode)}_relatedFeatureIntersectionObserverCreated(e){this._relatedFeatureIntersectionObserverNode=e}_unobserveRelatedFeatureObserver(){this._relatedFeatureIntersectionObserverNode&&this._relatedFeatureIntersectionObserver.unobserve(this._relatedFeatureIntersectionObserverNode)}};e([n()],F.prototype,"_relatedFeatureIntersectionObserverNode",void 0),e([n({readOnly:!0})],F.prototype,"displayShowAllButton",null),e([n({readOnly:!0})],F.prototype,"displayListItems",null),e([n()],F.prototype,"description",null),e([n({readOnly:!0})],F.prototype,"featureCountDescription",null),e([n()],F.prototype,"headingLevel",void 0),e([n()],F.prototype,"title",null),e([n({type:c})],F.prototype,"viewModel",void 0),e([n(),m("esri/widgets/Feature/t9n/Feature")],F.prototype,"messages",void 0),e([n(),m("esri/t9n/common")],F.prototype,"messagesCommon",void 0),e([n()],F.prototype,"visibleElements",void 0),e([a("visibleElements")],F.prototype,"castVisibleElements",null),F=e([l("esri.widgets.Feature.FeatureRelationship")],F);const _=F;export{_ as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{destroyMaybe as t}from"../../core/maybe.js";import{after as s}from"../../core/promiseUtils.js";import{watch as i,initial as r,on as o}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../core/accessorSupport/decorators/cast.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import d from"../Widget.js";import c from"./FeatureRelationship/FeatureRelationshipViewModel.js";import u from"./support/FeatureElementInfo.js";import{loadCalciteComponents as h}from"../support/componentsUtils.js";import{isRTL as p}from"../support/widgetUtils.js";import{messageBundle as m}from"../support/decorators/messageBundle.js";import{tsx as v}from"../support/jsxFactory.js";import{substitute as g}from"../../intl/substitute.js";const w="esri-feature",b=`${w}-relationship`,f={base:b,esriWidget:"esri-widget",listContainer:`${b}__list`,listItem:`${b}__list-item`,listItemHidden:`${b}__list-item--hidden`,listContainerQuerying:`${b}__list--querying`,featureObserver:`${w}__feature-observer`,stickySpinnerContainer:`${w}__sticky-loading-container`,loadingSpinnerContainer:`${w}__loading-container`,spinner:`${w}__loading-spinner`,iconLoading:"esri-icon-loading-indicator esri-rotating"},y={title:!0,description:!0};let F=class extends d{constructor(e,t){super(e,t),this._featureElementInfo=null,this._relatedFeatureIntersectionObserverNode=null,this._relatedFeatureIntersectionObserver=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this.headingLevel=2,this.viewModel=new c,this.messages=null,this.messagesCommon=null,this.visibleElements={...y},this._increaseFeaturePage=()=>{const{state:e,showAllEnabled:t,relatedFeatures:s,featuresPerPage:i,featurePage:r}=this.viewModel;"ready"===e&&t&&s.length>=i*r&&this.viewModel.featurePage++}}initialize(){this._featureElementInfo=new u,this.addHandles([i((()=>[this.viewModel.description,this.viewModel.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),r),i((()=>[this.viewModel.state,this.viewModel.showAllEnabled,this._relatedFeatureIntersectionObserverNode]),(()=>this._handleRelatedFeatureObserverChange())),o((()=>this.viewModel.relatedFeatureViewModels),"change",(()=>this._setupRelatedFeatureViewModels()))])}loadDependencies(){return h({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js")})}destroy(){this._unobserveRelatedFeatureObserver(),this._featureElementInfo=t(this._featureElementInfo)}get displayShowAllButton(){const{showAllEnabled:e,featureCount:t,displayCount:s,state:i}=this.viewModel;return!e&&!!t&&"ready"===i&&(t>s||0===s)}get displayListItems(){return this.displayShowAllButton||this.viewModel.relatedFeatureViewModels.length>0}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get featureCountDescription(){const{messages:e}=this,{featureCount:t}=this.viewModel;return g(e?.numberRecords,{number:t})}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}castVisibleElements(e){return{...y,...e}}renderStickyLoading(){return"querying"===this.viewModel.state?v("div",{key:"sticky-loader",class:f.stickySpinnerContainer},this.renderLoadingIcon()):null}renderLoadingIcon(){return v("span",{class:this.classes(f.iconLoading,f.spinner)})}renderLoading(){return v("div",{key:"loading-container",class:f.loadingSpinnerContainer},this.renderLoadingIcon())}renderShowAllIconNode(){return v("calcite-icon",{scale:"s",icon:"list",slot:"content-end"})}renderChevronIconNode(){const e=p(this.container)?"chevron-left":"chevron-right";return v("calcite-icon",{scale:"s",icon:e,slot:"content-end"})}renderRelatedFeature(e){const{itemDescriptionFieldName:t}=this.viewModel,s=e.title;e.description=t&&e.formattedAttributes?.global[t];const i="loading"===e.state;return v("calcite-list-item",{class:this.classes(f.listItem,{[f.listItemHidden]:i}),key:e.uid,label:s,description:e.description??"",onCalciteListItemSelect:()=>this.emit("select-record",{featureViewModel:e})},this.renderChevronIconNode())}renderShowAllListItem(){return this.displayShowAllButton?v("calcite-list-item",{key:"show-all-item",label:this.messages?.showAll,description:this.featureCountDescription,onCalciteListItemSelect:()=>this.emit("show-all-records")},this.renderShowAllIconNode()):null}renderNoRelatedFeaturesMessage(){return v("calcite-notice",{key:"no-related-features-message",icon:"information",open:!0,kind:"brand",scale:"s",width:"full"},v("div",{slot:"message"},this.messages?.noRelatedFeatures))}renderFeatureObserver(){return v("div",{key:"feature-observer",class:f.featureObserver,bind:this,afterCreate:this._relatedFeatureIntersectionObserverCreated})}renderList(){const{relatedFeatureViewModels:e}=this.viewModel;return v("calcite-list",null,e.toArray().map((e=>this.renderRelatedFeature(e))),this.renderShowAllListItem())}renderRelatedFeatures(){const{displayListItems:e}=this,{state:t}=this.viewModel;return v("div",{key:"list-container",class:this.classes(f.listContainer,{[f.listContainerQuerying]:"querying"===t})},e?this.renderList():"ready"===t?this.renderNoRelatedFeaturesMessage():null,this.renderStickyLoading(),this.renderFeatureObserver())}renderRelationshipNotFound(){return v("calcite-notice",{key:"relationship-not-found",icon:"exclamation-mark-triangle",open:!0,kind:"danger",scale:"s",width:"full"},v("div",{slot:"message"},this.messages?.relationshipNotFound))}render(){const{state:e}=this.viewModel;return v("div",{class:this.classes(f.base,f.esriWidget)},this._featureElementInfo?.render(),"loading"===e?this.renderLoading():"disabled"===e?this.renderRelationshipNotFound():this.renderRelatedFeatures())}_setupRelatedFeatureViewModels(){const{relatedFeatureViewModels:e}=this.viewModel,t="related-feature-viewmodels";this.removeHandles(t),e?.forEach((e=>{this.addHandles(i((()=>[e.title,e.state]),(()=>this.scheduleRender()),r),t)})),this.scheduleRender()}_setupFeatureElementInfo(){const{headingLevel:e,visibleElements:t}=this,s=t.description&&this.description,i=t.title&&this.title;this._featureElementInfo?.set({description:s,title:i,headingLevel:e})}async _handleRelatedFeatureObserverChange(){this._unobserveRelatedFeatureObserver();const{state:e,showAllEnabled:t}=this.viewModel;await s(0),this._relatedFeatureIntersectionObserverNode&&"ready"===e&&t&&this._relatedFeatureIntersectionObserver.observe(this._relatedFeatureIntersectionObserverNode)}_relatedFeatureIntersectionObserverCreated(e){this._relatedFeatureIntersectionObserverNode=e}_unobserveRelatedFeatureObserver(){this._relatedFeatureIntersectionObserverNode&&this._relatedFeatureIntersectionObserver.unobserve(this._relatedFeatureIntersectionObserverNode)}};e([n()],F.prototype,"_relatedFeatureIntersectionObserverNode",void 0),e([n({readOnly:!0})],F.prototype,"displayShowAllButton",null),e([n({readOnly:!0})],F.prototype,"displayListItems",null),e([n()],F.prototype,"description",null),e([n({readOnly:!0})],F.prototype,"featureCountDescription",null),e([n()],F.prototype,"headingLevel",void 0),e([n()],F.prototype,"title",null),e([n({type:c})],F.prototype,"viewModel",void 0),e([n(),m("esri/widgets/Feature/t9n/Feature")],F.prototype,"messages",void 0),e([n(),m("esri/t9n/common")],F.prototype,"messagesCommon",void 0),e([n()],F.prototype,"visibleElements",void 0),e([l("visibleElements")],F.prototype,"castVisibleElements",null),F=e([a("esri.widgets.Feature.FeatureRelationship")],F);const _=F;export{_ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{formatDate as r,formatTimestamp as n,formatTimeOnly as i,formatDateOnly as o,convertDateFormatToIntlOptions as a}from"../../../intl/date.js";import{formatNumber as l,convertNumberFormatToIntlOptions as u}from"../../../intl/number.js";import{isRasterPixelValueField as s,featureHasFields as f}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as c,getEffectiveLayerCapabilities as d}from"../../../layers/support/layerUtils.js";import p from"../../../popup/support/FieldInfoFormat.js";import{loadArcade as y}from"../../../support/arcadeOnDemand.js";const m="esri.widgets.Feature.support.featureUtils",g=e.getLogger(m),h=/href=(""|'')/gi,I=/(\{([^\{\r\n]+)\})/g,b=/\'/g,F=/^\s*expression\//i,w=/(\n)/gi,N=/[\u00A0-\u9999<>\&]/gim,j=/href\s*=\s*(?:\"([^\"]+)\"|\'([^\']+)\')/gi,E=/^(?:mailto:|tel:)/,T="relationships/",x=a("short-date-short-time");function C(e){if(null!=e)return e.get("sourceLayer")||e.get("layer")}async function q(e,t){return"function"==typeof e?e(t):e}function A(e=""){if(e)return!E.test(e.trim().toLowerCase())}function M(e){return!!e&&F.test(e)}function R(e,t){if(!M(t)||!e)return null;const r=t.replace(F,"").toLowerCase();let n=null;return e.some((e=>e.name.toLowerCase()===r&&(n=e,!0))),n}function D(e,t){const r=R(t,e?.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function v(e,t){const r=t.get(e.toLowerCase());return`{${r&&r.fieldName||e}}`}function L(e){return e.replaceAll(h,"")}function U(e,t){const r=O(t,e);return r?r.name:e}function $(e,t){return e&&e.map((e=>U(e,t)))}function O(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function S(e){return`${e}`.trim()}function G({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?k({formattedAttributes:t,template:H(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function k({formattedAttributes:e,template:r,fieldInfoMap:n}){return S(L(t(t(r,(e=>v(e,n))),e)))}function P(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replaceAll(b,i);t[e]=o}}function Q(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>P(e,r,t))),r}function _(e,r,n){const i=(r=S(r))&&"{"!==r[0];return t(e,Q(n,i||!1))}function z(e,t){return e.replaceAll(I,((e,r,n)=>{const i=O(t,n);return i?`{${i.name}}`:r}))}function H(e,t,r){const n=z(e,r);return n?n.replaceAll(j,((e,r,n)=>_(e,r||n,t))):n}function V(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function Z(e){return null!=e&&"object"==typeof e&&"layer"in e&&!!e.layer}function B(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-image"===e.type}function J(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&"feature"===e.type&&"when"in e}function K(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function W(e){return J(e)&&K(e)}function X(e,t){const{fieldInfos:r,fieldName:n,preventPlacesFormatting:i,layer:o}=t,a=Y(r,n),f=a?.clone(),d=O(o,n);if(f&&!s(n)){const t=d?.type;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t){const r=f.format??new p;if(r.dateFormat??="date-only"===t?"short-date":"short-date-short-time","number"==typeof e){const t=!Z(o)&&c(o)&&o.datesInUnknownTimezone||Z(o)&&B(o.layer)&&o.layer.datesInUnknownTimezone;return r.formatDate(e,t)}switch(t){case"date-only":return r.formatDateOnly(e);case"time-only":return r.formatTimeOnly(e);case"timestamp-offset":return r.formatTimestamp(e)}}}const y=f?.format;return"string"==typeof e&&s(n)&&y?y.formatRasterPixelValue(e):"string"==typeof(e=V(e,y))||null==e||null==y?ae(e):i?l(e,{...u(y),minimumFractionDigits:0,maximumFractionDigits:20}):y.formatNumber(e)}function Y(e,t){if(e&&e.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function ee({fieldName:e,graphic:t,layer:r}){if(de(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function te({fieldName:e,value:t,graphic:r,layer:n}){if(de(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=r&&n.getFieldDomain(e,{feature:r});return i&&"coded-value"===i.type?i.getName(t):null}function re(e,t){const{creatorField:n,creationDateField:i,editorField:o,editDateField:a}=e;if(!t)return;const l=t[a];if("number"==typeof l){const e=t[o];return{type:"edit",date:r(l,x),user:e}}const u=t[i];if("number"==typeof u){const e=t[n];return{type:"create",date:r(u,x),user:e}}return null}function ne(e,t){const r=new Map;return e?(e.forEach((e=>{const n=U(e.fieldName,t);e.fieldName=n,r.set(n.toLowerCase(),e)})),r):r}function ie(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e&&e.fieldInfos;r&&t.push(...r)}})),t):t}function oe(e){return e.replaceAll(N,(e=>`&#${e.charCodeAt(0)};`))}function ae(e){return"string"==typeof e?e.replaceAll(w,'<br class="esri-text-new-line" />'):e}function le(e){const{value:t,fieldName:a,fieldInfos:l,fieldInfoMap:u,layer:s,graphic:f}=e;if(null==t)return"";const c=te({fieldName:a,value:t,graphic:f,layer:s});if(c)return c;const d=ee({fieldName:a,graphic:f,layer:s});if(d)return d;if(u.get(a.toLowerCase()))return X(t,{fieldInfos:l||Array.from(u.values()),fieldName:a,layer:s});switch(s?.fieldsIndex?.get(a)?.type){case"date":return r(t);case"date-only":return o(t);case"time-only":return i(t);case"timestamp-offset":return n(t)}return ae(t)}function ue({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o}){const a={};return o?.forEach((t=>me({attributes:a,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r}))),t&&Object.keys(t).forEach((o=>{const l=t[o];a[o]=le({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:l,graphic:n})})),a}async function se(e,t){const{layer:r,graphic:n,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:r,graphic:n,objectId:u,requiredFields:i};return g.warn(e,t),null}if(!d(r)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:r,graphic:n,requiredFields:i,returnGeometry:a};return g.warn(e,t),null}const s=r.createQuery();s.objectIds=o,s.outFields=i?.length?i:[r.objectIdField],s.returnGeometry=!!a,s.returnZ=!!a,s.returnM=!!a,s.outSpatialReference=l;return(await r.queryFeatures(s,t)).features[0]}async function fe(e){if(!e.expressionInfos?.length)return!1;const t=await y(),{arcadeUtils:{hasGeometryFunctions:r}}=t;return r(e)}async function ce({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=e.attributes[r.objectIdField];if(null==o)return;const a=[o],l=await t.getRequiredFields(r.fieldsIndex),u=f(l,e),s=u?[]:l,c=t.returnGeometry||await fe(t);if(u&&!c)return;const d=await se({layer:r,graphic:e,outFields:s,objectIds:a,returnGeometry:c,spatialReference:n},i);d&&(d.geometry&&(e.geometry=d.geometry),d.attributes&&(e.attributes={...e.attributes,...d.attributes}))}function de(e=""){return!!e&&e.includes(T)}function pe(e){return e?`${T}${e.layerId}/${e.fieldName}`:""}function ye({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o}){e&&t&&r&&Object.keys(t.attributes).forEach((a=>{const l=pe({layerId:r.relation.id.toString(),fieldName:a}),u=t.attributes[a];e[l]=le({fieldName:l,fieldInfos:n,fieldInfoMap:i,layer:o,value:u,graphic:t})}))}function me({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}){e&&t&&(t.relatedFeatures&&t.relatedFeatures&&t.relatedFeatures.forEach((o=>ye({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))),t.relatedStatsFeatures&&t.relatedStatsFeatures&&t.relatedStatsFeatures.forEach((o=>ye({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},he=({layer:e,method:t,query:r,definitionExpression:n})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=r.where?r.where:null,o=null!=r.geometry?r.geometry:null;ge(n)||ge(i)||"extent"===o?.type||"tile"===r.resultType||(r.cacheHint=!0)},Ie=({query:e,layer:t,method:r})=>{he({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})},be=({queryPayload:e,layer:t,method:r})=>{he({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})};function Fe(e,t,r){return e&&t&&r?we(e.allLayers,t,r)||we(e.allTables,t,r):null}function we(e,t,r){return e.filter(W).find((e=>e!==t&&e.url===t.url&&e.layerId===r.relatedTableId))}export{ae as applyTextFormattingHTML,ne as createfieldInfoMap,Fe as findRelatedLayer,z as fixTokens,ue as formatAttributes,re as formatEditInfo,X as formatValueToFieldInfo,ie as getAllFieldInfos,Y as getFieldInfo,D as getFieldInfoLabel,U as getFixedFieldName,$ as getFixedFieldNames,C as getSourceLayer,q as graphicCallback,oe as htmlEntities,M as isExpressionField,J as isFeatureSupportedLayer,W as isRelatableFeatureSupportedLayer,K as isRelatableLayer,de as isRelatedField,Ie as preLayerQueryCallback,be as preRequestCallback,se as querySourceLayer,ce as queryUpdatedFeature,A as shouldOpenInNewTab,k as substituteAttributes,G as substituteFieldsInLinksAndAttributes};
5
+ import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{formatDate as r,formatTimestamp as n,formatTimeOnly as i,formatDateOnly as o,convertDateFormatToIntlOptions as a}from"../../../intl/date.js";import{formatNumber as l,convertNumberFormatToIntlOptions as u}from"../../../intl/number.js";import{isRasterPixelValueField as s,featureHasFields as f}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as c,getEffectiveLayerCapabilities as d}from"../../../layers/support/layerUtils.js";import p from"../../../popup/support/FieldInfoFormat.js";import{loadArcade as y}from"../../../support/arcadeOnDemand.js";const m="esri.widgets.Feature.support.featureUtils",g=e.getLogger(m),h=/href=(""|'')/gi,I=/(\{([^\{\r\n]+)\})/g,b=/\'/g,F=/^\s*expression\//i,w=/(\n)/gi,N=/[\u00A0-\u9999<>\&]/gim,j=/href\s*=\s*(?:\"([^\"]+)\"|\'([^\']+)\')/gi,E=/^(?:mailto:|tel:)/,T="relationships/",x=a("short-date-short-time");function C(e){if(null!=e)return e.get("sourceLayer")||e.get("layer")}async function q(e,t){return"function"==typeof e?e(t):e}function A(e=""){if(e)return!E.test(e.trim().toLowerCase())}function M(e){return!!e&&F.test(e)}function R(e,t){if(!M(t)||!e)return null;const r=t.replace(F,"").toLowerCase();let n=null;return e.some((e=>e.name.toLowerCase()===r&&(n=e,!0))),n}function L(e,t){const r=R(t,e?.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function D(e,t){const r=t.get(e.toLowerCase());return`{${r&&r.fieldName||e}}`}function v(e){return e.replaceAll(h,"")}function U(e,t){const r=O(t,e);return r?r.name:e}function $(e,t){return e&&e.map((e=>U(e,t)))}function O(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function S(e){return`${e}`.trim()}function G({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?k({formattedAttributes:t,template:H(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function k({formattedAttributes:e,template:r,fieldInfoMap:n}){return S(v(t(t(r,(e=>D(e,n))),e)))}function P(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replaceAll(b,i);t[e]=o}}function Q(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>P(e,r,t))),r}function _(e,r,n){const i=(r=S(r))&&"{"!==r[0];return t(e,Q(n,i||!1))}function z(e,t){return e.replaceAll(I,((e,r,n)=>{const i=O(t,n);return i?`{${i.name}}`:r}))}function H(e,t,r){const n=z(e,r);return n?n.replaceAll(j,((e,r,n)=>_(e,r||n,t))):n}function V(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function Z(e){return null!=e&&"object"==typeof e&&"layer"in e&&!!e.layer}function B(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-image"===e.type}function J(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&"feature"===e.type&&"when"in e}function K(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function W(e){return J(e)&&K(e)}function X(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&W(e.sourceLayer)}function Y(e,t){const{fieldInfos:r,fieldName:n,preventPlacesFormatting:i,layer:o}=t,a=ee(r,n),f=a?.clone(),d=O(o,n);if(f&&!s(n)){const t=d?.type;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t){const r=f.format??new p;if(r.dateFormat??="date-only"===t?"short-date":"short-date-short-time","number"==typeof e){const t=!Z(o)&&c(o)&&o.datesInUnknownTimezone||Z(o)&&B(o.layer)&&o.layer.datesInUnknownTimezone;return r.formatDate(e,t)}switch(t){case"date-only":return r.formatDateOnly(e);case"time-only":return r.formatTimeOnly(e);case"timestamp-offset":return r.formatTimestamp(e)}}}const y=f?.format;return"string"==typeof e&&s(n)&&y?y.formatRasterPixelValue(e):"string"==typeof(e=V(e,y))||null==e||null==y?le(e):i?l(e,{...u(y),minimumFractionDigits:0,maximumFractionDigits:20}):y.formatNumber(e)}function ee(e,t){if(e&&e.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function te({fieldName:e,graphic:t,layer:r}){if(pe(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function re({fieldName:e,value:t,graphic:r,layer:n}){if(pe(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=r&&n.getFieldDomain(e,{feature:r});return i&&"coded-value"===i.type?i.getName(t):null}function ne(e,t){const{creatorField:n,creationDateField:i,editorField:o,editDateField:a}=e;if(!t)return;const l=t[a];if("number"==typeof l){const e=t[o];return{type:"edit",date:r(l,x),user:e}}const u=t[i];if("number"==typeof u){const e=t[n];return{type:"create",date:r(u,x),user:e}}return null}function ie(e,t){const r=new Map;return e?(e.forEach((e=>{const n=U(e.fieldName,t);e.fieldName=n,r.set(n.toLowerCase(),e)})),r):r}function oe(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e&&e.fieldInfos;r&&t.push(...r)}})),t):t}function ae(e){return e.replaceAll(N,(e=>`&#${e.charCodeAt(0)};`))}function le(e){return"string"==typeof e?e.replaceAll(w,'<br class="esri-text-new-line" />'):e}function ue(e){const{value:t,fieldName:a,fieldInfos:l,fieldInfoMap:u,layer:s,graphic:f}=e;if(null==t)return"";const c=re({fieldName:a,value:t,graphic:f,layer:s});if(c)return c;const d=te({fieldName:a,graphic:f,layer:s});if(d)return d;if(u.get(a.toLowerCase()))return Y(t,{fieldInfos:l||Array.from(u.values()),fieldName:a,layer:s});switch(s?.fieldsIndex?.get(a)?.type){case"date":return r(t);case"date-only":return o(t);case"time-only":return i(t);case"timestamp-offset":return n(t)}return le(t)}function se({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o}){const a={};return o?.forEach((t=>ge({attributes:a,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r}))),t&&Object.keys(t).forEach((o=>{const l=t[o];a[o]=ue({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:l,graphic:n})})),a}async function fe(e,t){const{layer:r,graphic:n,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:r,graphic:n,objectId:u,requiredFields:i};return g.warn(e,t),null}if(!d(r)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:r,graphic:n,requiredFields:i,returnGeometry:a};return g.warn(e,t),null}const s=r.createQuery();s.objectIds=o,s.outFields=i?.length?i:[r.objectIdField],s.returnGeometry=!!a,s.returnZ=!!a,s.returnM=!!a,s.outSpatialReference=l;return(await r.queryFeatures(s,t)).features[0]}async function ce(e){if(!e.expressionInfos?.length)return!1;const t=await y(),{arcadeUtils:{hasGeometryFunctions:r}}=t;return r(e)}async function de({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=e.attributes[r.objectIdField];if(null==o)return;const a=[o],l=await t.getRequiredFields(r.fieldsIndex),u=f(l,e),s=u?[]:l,c=t.returnGeometry||await ce(t);if(u&&!c)return;const d=await fe({layer:r,graphic:e,outFields:s,objectIds:a,returnGeometry:c,spatialReference:n},i);d&&(d.geometry&&(e.geometry=d.geometry),d.attributes&&(e.attributes={...e.attributes,...d.attributes}))}function pe(e=""){return!!e&&e.includes(T)}function ye(e){return e?`${T}${e.layerId}/${e.fieldName}`:""}function me({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o}){e&&t&&r&&Object.keys(t.attributes).forEach((a=>{const l=ye({layerId:r.relation.id.toString(),fieldName:a}),u=t.attributes[a];e[l]=ue({fieldName:l,fieldInfos:n,fieldInfoMap:i,layer:o,value:u,graphic:t})}))}function ge({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}){e&&t&&(t.relatedFeatures&&t.relatedFeatures&&t.relatedFeatures.forEach((o=>me({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))),t.relatedStatsFeatures&&t.relatedStatsFeatures&&t.relatedStatsFeatures.forEach((o=>me({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))))}const he=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},Ie=({layer:e,method:t,query:r,definitionExpression:n})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=r.where?r.where:null,o=null!=r.geometry?r.geometry:null;he(n)||he(i)||"extent"===o?.type||"tile"===r.resultType||(r.cacheHint=!0)},be=({query:e,layer:t,method:r})=>{Ie({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})},Fe=({queryPayload:e,layer:t,method:r})=>{Ie({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})};function we(e,t,r){return e&&t&&r?Ne(e.allLayers,t,r)||Ne(e.allTables,t,r):null}function Ne(e,t,r){return e.filter(W).find((e=>e!==t&&e.url===t.url&&e.layerId===r.relatedTableId))}export{le as applyTextFormattingHTML,ie as createfieldInfoMap,we as findRelatedLayer,z as fixTokens,se as formatAttributes,ne as formatEditInfo,Y as formatValueToFieldInfo,oe as getAllFieldInfos,ee as getFieldInfo,L as getFieldInfoLabel,U as getFixedFieldName,$ as getFixedFieldNames,C as getSourceLayer,q as graphicCallback,ae as htmlEntities,M as isExpressionField,J as isFeatureSupportedLayer,X as isGraphicForRelatableFeatureSupportedLayer,W as isRelatableFeatureSupportedLayer,K as isRelatableLayer,pe as isRelatedField,be as preLayerQueryCallback,Fe as preRequestCallback,fe as querySourceLayer,de as queryUpdatedFeature,A as shouldOpenInNewTab,k as substituteAttributes,G as substituteFieldsInLinksAndAttributes};
@@ -1,4 +1,4 @@
1
1
  import "../../interfaces";
2
2
 
3
- import FeatureFormEditableInput = __esri.FeatureFormEditableInput;
4
- export default FeatureFormEditableInput;
3
+ import EditableInput = __esri.EditableInput;
4
+ export default EditableInput;
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{deprecatedProperty as n}from"../../core/deprecate.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import o from"../../core/Logger.js";import{destroyMaybe as r}from"../../core/maybe.js";import{EsriPromiseMixin as a}from"../../core/Promise.js";import{watch as l}from"../../core/reactiveUtils.js";import{templateHasKey as u}from"../../core/string.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{flattenFieldInputs as g,flattenRelationshipInputs as y,parseFormTemplateString as _,isGroupInput as v,isGroupElement as C,isFieldElement as E,isRelationshipElement as I,isRelationshipInput as F,isFieldInput as x,getNormalizedFeatureTypeInfo as b}from"./featureFormUtils.js";import V from"./FieldInput.js";import{createFormExpressionArcadeExecutor as w}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as j}from"./FormExpressionsManager.js";import A from"./GroupInput.js";import T from"./RelationshipInput.js";const M=new t({attributes:{}}),R=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],L=["visibilityExpression"],N=["editableExpression","visibilityExpression"],S="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",k="#JSAPI_CONTINGENT_VALUE_ANY_HASH",P="#JSAPI_CONTINGENT_VALUE_NULL_HASH",H="esri.widgets.FeatureForm.FeatureFormViewModel",G=o.getLogger(H);let U=class extends(i(a(s.EventedAccessor))){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=M.clone(),this._initialFeature=M.clone(),this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.inputs=[],this.map=null,this.relatedRecordCallbacks=null,this.strict=!1}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate]),(([e,t])=>{null!=e&&(t?this._updateInputs():e.load().catch((()=>o.getLogger(this).error("Failed to load layer",e.loadError))))}),{equals:([e,t,n],[s,i,o])=>e===s&&t===i&&n===o,initial:!0}),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e)})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.handles.add([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=r(this._contingentValuesCache)}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i}=this;return{layer:f(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i}}get allFieldInputs(){return g(this.inputs)}get allRelationshipInputs(){return y(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():M.clone(),this._initialFeature=this._featureClone.clone(),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),this.contingencyConstraintViolations.clear(),null!=this._expressionsManager&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this.updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return null!=e&&e.description&&t?_(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return null!=e&&e.title&&t?_(e.title,this.getValues(),t.fieldsIndex):null}formHeaderVisible(){const{activeRelationshipInput:e,formDescription:t,formTitle:n}=this;return!(e||!t&&!n)}set inputFields(e){n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs=e}get inputFields(){return n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>e.showAllEnabled=!1)),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get updating(){return this.updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}get view(){return n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._get("view")}set view(e){n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._set("view",e),e?.map&&(this.map=e.map)}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:n}=this,s=!!n?.getField(e);return t.getAttribute(e)??(s?null:void 0)}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),null!=this._expressionsManager&&this.updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:n}=this;n.geometry=t.geometry,null!=e&&this.updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}_updateInputs(){const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,map:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,map:r},l=i.slice(),u=null!=s&&s.elements&&s.elements.length>0?this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u}_updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(v(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(O),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});this.updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=g(o);return this._createExpressionsManager(e,t),this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[r,a]of s.entries())s.delete(r),a.destroy();return o}_updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):C(a)?this._makeGroupInputFromElement(a,s):E(a)?this._makeFieldInputFromElement(a,s,i):I(a)?this._makeRelationshipInputFromElement(a,s,i):null;if(n){if(r.push(n),e)if(t.delete(a),v(n)){const{feature:e}=s;n.set({feature:e})}else if(F(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({element:a,showAllEnabled:e})}else n.set(s);else this._assignExpressionExecutors(n,a,o);if(C(a)){const e=a.elements.filter((e=>O(e)));n.inputs=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return o.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(v(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else F(o)?o.destroy():x(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[],{arcadeEditType:r,feature:a,initialFeature:l,layer:u}=n;for(const o of t){const e=s.get(o)??new V({arcadeEditType:r,field:o,feature:a,initialFeature:l,layer:u,value:a?.getAttribute(o.name)??null});i.push(e),s.delete(o)}for(const[o,p]of s.entries())s.delete(o),p.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r}=t,{fieldName:a}=e,l=a&&this._layerFieldsByName.get(a);return l?new V({arcadeEditType:s,element:e,field:l,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n}):null}_makeGroupInputFromElement(e,t){const{feature:n,layer:s}=t;return new A({element:e,inputs:[],feature:n,layer:s})}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o}=t;return new T({element:e,feature:i,group:n,layer:o,map:s})}_assignExpressionExecutors(e,t,n){const s=C(t)?L:I(t)?N:R,i=[];for(const o of s){const s=t[o],{_expressionExecutorLookup:i}=this;if(null!=s&&""!==s){const t=`${o}Executor`,r=this._expressionLookup.get(s)??this._addToExpressionLookup(s);if(i.has(r))e[t]=i.get(r);else if(n.has(r)){const s=n.get(r).then((n=>(e[t]=n,n)));n.set(r,s)}else{const s=w(r,this.layer).then((n=>(e[t]=n,i.set(r,n),n)));n.set(r,s)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:n,_featureClone:s}=this;this._expressionsManager=new j({executors:e,feature:s,arcadeContextInfo:n,fieldInputs:t})}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=b(o);if(t===a&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);s.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(null!=i){const{description:e,title:n}=i;n&&u(n,t)&&this.notifyChange("formTitle"),e&&u(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:n}=this,s=null!=n&&null!=n.expressionInfos?Object.values(n.expressionInfos).find((t=>t.name===e)):null,i=s?.expression??e;return t.set(e,i),e!==i&&t.set(i,i),i}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=b(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(k)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(k),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(k)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(k),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:d,rightIsRange:f}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&d)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(n.minValue,o.minValue),g=Math.min(n.maxValue,o.maxValue);if(m>g)return null;s.values[i]=new h({objectType:"range",minValue:m,maxValue:g})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===k)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,r=new Set,a=new Set;for(const l of i)if(o.has(l)){const e=this.layer?.getFieldDomain(l,{feature:this.feature});if(null==e)continue;switch(e.type){case"coded-value":r.add(l);break;case"range":a.add(l)}}return{codedValueFields:[...r],rangeFields:[...a]}}_hashContingency(e,t,n=!1){if(t.length<1)return[S,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[k,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${P}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};function O(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||(o.getLogger(H).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}e([p()],U.prototype,"_featureClone",void 0),e([p()],U.prototype,"activeRelationshipInput",null),e([p()],U.prototype,"_arcadeContextInfo",null),e([p({readOnly:!0})],U.prototype,"allFieldInputs",null),e([p()],U.prototype,"allRelationshipInputs",null),e([p()],U.prototype,"_layerFieldsByName",null),e([p()],U.prototype,"arcadeEditType",void 0),e([p()],U.prototype,"contingencyConstraintViolations",void 0),e([p()],U.prototype,"disabled",void 0),e([p()],U.prototype,"feature",null),e([p()],U.prototype,"fieldsWithContingentValues",null),e([p({type:d})],U.prototype,"formTemplate",null),e([p()],U.prototype,"formDescription",null),e([p()],U.prototype,"formTitle",null),e([p()],U.prototype,"formHeaderVisible",null),e([p()],U.prototype,"inputs",void 0),e([p()],U.prototype,"inputFields",null),e([p()],U.prototype,"joinedContingentValues",null),e([p()],U.prototype,"layer",null),e([p()],U.prototype,"map",void 0),e([p()],U.prototype,"relatedRecordCallbacks",void 0),e([p()],U.prototype,"relationshipId",null),e([p()],U.prototype,"spatialReference",null),e([p()],U.prototype,"state",null),e([p()],U.prototype,"strict",void 0),e([p()],U.prototype,"submittable",null),e([p()],U.prototype,"updating",null),e([p()],U.prototype,"valid",null),e([p()],U.prototype,"view",null),e([p()],U.prototype,"getValues",null),e([p()],U.prototype,"submit",null),U=e([c(H)],U);const $=U;export{$ as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{deprecatedProperty as n}from"../../core/deprecate.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import o from"../../core/Logger.js";import{destroyMaybe as r}from"../../core/maybe.js";import{EsriPromiseMixin as a}from"../../core/Promise.js";import{watch as l}from"../../core/reactiveUtils.js";import{templateHasKey as u}from"../../core/string.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{flattenFieldInputs as g,flattenRelationshipInputs as y,parseFormTemplateString as _,isGroupInput as v,isGroupElement as C,isFieldElement as E,isRelationshipElement as I,isRelationshipInput as F,isFieldInput as x,getNormalizedFeatureTypeInfo as b}from"./featureFormUtils.js";import V from"./FieldInput.js";import{createFormExpressionArcadeExecutor as w}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as j}from"./FormExpressionsManager.js";import A from"./GroupInput.js";import T from"./RelationshipInput.js";const M=new t({attributes:{}}),R=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],L=["visibilityExpression"],N=["editableExpression","visibilityExpression"],S="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",k="#JSAPI_CONTINGENT_VALUE_ANY_HASH",P="#JSAPI_CONTINGENT_VALUE_NULL_HASH",H="esri.widgets.FeatureForm.FeatureFormViewModel",G=o.getLogger(H);let U=class extends(i(a(s.EventedAccessor))){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=M.clone(),this._initialFeature=M.clone(),this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.inputs=[],this.map=null,this.relatedRecordCallbacks=null,this.strict=!1}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate]),(([e,t])=>{null!=e&&(t?this._updateInputs():e.load().catch((()=>o.getLogger(this).error("Failed to load layer",e.loadError))))}),{equals:([e,t,n],[s,i,o])=>e===s&&t===i&&n===o,initial:!0}),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e)})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.handles.add([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=r(this._contingentValuesCache)}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i}=this;return{layer:f(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i}}get allFieldInputs(){return g(this.inputs)}get allRelationshipInputs(){return y(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():M.clone(),this._initialFeature=this._featureClone.clone(),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),this.contingencyConstraintViolations.clear(),null!=this._expressionsManager&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this.updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return null!=e&&e.description&&t?_(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return null!=e&&e.title&&t?_(e.title,this.getValues(),t.fieldsIndex):null}formHeaderVisible(){const{activeRelationshipInput:e,formDescription:t,formTitle:n}=this;return!(e||!t&&!n)}set inputFields(e){n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs=e}get inputFields(){return n(G,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>e.showAllEnabled=!1)),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get updating(){return this.updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}get view(){return n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._get("view")}set view(e){n(G,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._set("view",e),e?.map&&(this.map=e.map)}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:n}=this,s=!!n?.getField(e);return t.getAttribute(e)??(s?null:void 0)}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),null!=this._expressionsManager&&this.updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:n}=this;n.geometry=t.geometry,null!=e&&this.updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}_updateInputs(){const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,map:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,map:r},l=i.slice(),u=null!=s&&s.elements&&s.elements.length>0?this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u}_updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(v(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(O),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});this.updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=g(o);return this._createExpressionsManager(e,t),this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[r,a]of s.entries())s.delete(r),a.destroy();return o}_updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):C(a)?this._makeGroupInputFromElement(a,s):E(a)?this._makeFieldInputFromElement(a,s,i):I(a)?this._makeRelationshipInputFromElement(a,s,i):null;if(n){if(r.push(n),e)if(t.delete(a),v(n)){const{feature:e}=s;n.set({feature:e})}else if(F(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({showAllEnabled:e})}else n.set(s);else this._assignExpressionExecutors(n,a,o);if(C(a)){const e=a.elements.filter((e=>O(e)));n.inputs=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return o.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(v(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else F(o)?o.destroy():x(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[],{arcadeEditType:r,feature:a,initialFeature:l,layer:u}=n;for(const o of t){const e=s.get(o)??new V({arcadeEditType:r,field:o,feature:a,initialFeature:l,layer:u,value:a?.getAttribute(o.name)??null});i.push(e),s.delete(o)}for(const[o,p]of s.entries())s.delete(o),p.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r}=t,{fieldName:a}=e,l=a&&this._layerFieldsByName.get(a);return l?new V({arcadeEditType:s,element:e,field:l,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n}):null}_makeGroupInputFromElement(e,t){const{feature:n,layer:s}=t;return new A({element:e,inputs:[],feature:n,layer:s})}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o}=t;return new T({element:e,feature:i,group:n,layer:o,map:s})}_assignExpressionExecutors(e,t,n){const s=C(t)?L:I(t)?N:R,i=[];for(const o of s){const s=t[o],{_expressionExecutorLookup:i}=this;if(null!=s&&""!==s){const t=`${o}Executor`,r=this._expressionLookup.get(s)??this._addToExpressionLookup(s);if(i.has(r))e[t]=i.get(r);else if(n.has(r)){const s=n.get(r).then((n=>(e[t]=n,n)));n.set(r,s)}else{const s=w(r,this.layer).then((n=>(e[t]=n,i.set(r,n),n)));n.set(r,s)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:n,_featureClone:s}=this;this._expressionsManager=new j({executors:e,feature:s,arcadeContextInfo:n,fieldInputs:t})}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=b(o);if(t===a&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);s.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(null!=i){const{description:e,title:n}=i;n&&u(n,t)&&this.notifyChange("formTitle"),e&&u(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_addToExpressionLookup(e){const{_expressionLookup:t,formTemplate:n}=this,s=null!=n&&null!=n.expressionInfos?Object.values(n.expressionInfos).find((t=>t.name===e)):null,i=s?.expression??e;return t.set(e,i),e!==i&&t.set(i,i),i}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=b(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(k)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(k),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(k)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(k),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:d,rightIsRange:f}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&d)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(n.minValue,o.minValue),g=Math.min(n.maxValue,o.maxValue);if(m>g)return null;s.values[i]=new h({objectType:"range",minValue:m,maxValue:g})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===k)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,r=new Set,a=new Set;for(const l of i)if(o.has(l)){const e=this.layer?.getFieldDomain(l,{feature:this.feature});if(null==e)continue;switch(e.type){case"coded-value":r.add(l);break;case"range":a.add(l)}}return{codedValueFields:[...r],rangeFields:[...a]}}_hashContingency(e,t,n=!1){if(t.length<1)return[S,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[k,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${P}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};function O(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||(o.getLogger(H).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}e([p()],U.prototype,"_featureClone",void 0),e([p()],U.prototype,"activeRelationshipInput",null),e([p()],U.prototype,"_arcadeContextInfo",null),e([p({readOnly:!0})],U.prototype,"allFieldInputs",null),e([p()],U.prototype,"allRelationshipInputs",null),e([p()],U.prototype,"_layerFieldsByName",null),e([p()],U.prototype,"arcadeEditType",void 0),e([p()],U.prototype,"contingencyConstraintViolations",void 0),e([p()],U.prototype,"disabled",void 0),e([p()],U.prototype,"feature",null),e([p()],U.prototype,"fieldsWithContingentValues",null),e([p({type:d})],U.prototype,"formTemplate",null),e([p()],U.prototype,"formDescription",null),e([p()],U.prototype,"formTitle",null),e([p()],U.prototype,"formHeaderVisible",null),e([p()],U.prototype,"inputs",void 0),e([p()],U.prototype,"inputFields",null),e([p()],U.prototype,"joinedContingentValues",null),e([p()],U.prototype,"layer",null),e([p()],U.prototype,"map",void 0),e([p()],U.prototype,"relatedRecordCallbacks",void 0),e([p()],U.prototype,"relationshipId",null),e([p()],U.prototype,"spatialReference",null),e([p()],U.prototype,"state",null),e([p()],U.prototype,"strict",void 0),e([p()],U.prototype,"submittable",null),e([p()],U.prototype,"updating",null),e([p()],U.prototype,"valid",null),e([p()],U.prototype,"view",null),e([p()],U.prototype,"getValues",null),e([p()],U.prototype,"submit",null),U=e([c(H)],U);const $=U;export{$ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as r}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import i from"../Feature/FeatureRelationship/FeatureRelationshipViewModel.js";import{isRelatableFeatureSupportedLayer as l}from"../Feature/support/featureUtils.js";import a from"./EditableInput.js";const n=3;let p=class extends a{constructor(e){super(e),this._relationshipVM=null,this.group=null,this.type="relationship",this.handles.add([t((()=>({feature:this.feature,element:this.element,layer:this.layer})),(e=>this._createRelationshipVM(e)),r)])}destroy(){this._relationshipVM?.destroy()}get canAddRelatedFeature(){const{editable:e,featureCount:t,_relationshipVM:r}=this;if(!r?.relationship)return!1;const{cardinality:s,role:o}=r.relationship;return!("one-to-one"===s&&t>0)&&("many-to-many"!==s&&(!("one-to-many"===s&&"destination"===o&&t>0)&&e))}get displayCount(){return this.element.displayCount??n}get displayType(){return this.element.displayType}get editable(){return!!this.layerAllowsEdits&&(this.evaluatedEditableExpression??!0)}get featureCount(){return this._relationshipVM?.featureCount??0}get map(){return this._get("map")}set map(e){e&&this._relationshipVM?.set("map",e),this._set("map",e)}get orderByFields(){return this.element.orderByFields}get relationshipId(){return this.element.relationshipId}get relatedFeatureInfos(){return this._relationshipVM?.relatedFeatureInfos??[]}get relatedLayer(){return this._relationshipVM?.relatedLayer}get showAllEnabled(){return this._get("showAllEnabled")}set showAllEnabled(e){this._relationshipVM?.set("showAllEnabled",e),this._set("showAllEnabled",e)}get showAllActionVisible(){return!this.showAllEnabled&&this.featureCount>0&&this.featureCount>this.displayCount}get updating(){return"loading"===this._relationshipVM?.state||"querying"===this._relationshipVM?.state}incrementPage(){this._relationshipVM&&this._relationshipVM.featurePage++}getRelatedFeatureByObjectId(e){return this._relationshipVM?.getRelatedFeatureByObjectId(e)}_createRelationshipVM(e){const{feature:t,element:r,layer:s}=e;if(this._relationshipVM?.destroy(),!t||!r||!s)return;const{displayCount:o,map:a,orderByFields:n,relationshipId:p,showAllEnabled:u}=this;l(s)&&(this._relationshipVM=new i({graphic:t,displayCount:o,layer:s,map:a,orderByFields:n,relationshipId:p,showAllEnabled:u}))}};e([s()],p.prototype,"canAddRelatedFeature",null),e([s()],p.prototype,"displayCount",null),e([s()],p.prototype,"displayType",null),e([s()],p.prototype,"editable",null),e([s()],p.prototype,"group",void 0),e([s()],p.prototype,"map",null),e([s()],p.prototype,"orderByFields",null),e([s()],p.prototype,"relationshipId",null),e([s()],p.prototype,"relatedFeatureInfos",null),e([s()],p.prototype,"relatedLayer",null),e([s()],p.prototype,"showAllEnabled",null),e([s()],p.prototype,"showAllActionVisible",null),e([s({readOnly:!0})],p.prototype,"type",void 0),e([s()],p.prototype,"updating",null),e([s()],p.prototype,"incrementPage",null),e([s()],p.prototype,"getRelatedFeatureByObjectId",null),p=e([o("esri.widgets.FeatureForm.RelationshipInput")],p);const u=p;export{u as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t,initial as r}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import i from"../Feature/FeatureRelationship/FeatureRelationshipViewModel.js";import{isRelatableFeatureSupportedLayer as l}from"../Feature/support/featureUtils.js";import a from"./EditableInput.js";const n=3;let p=class extends a{constructor(e){super(e),this._relationshipVM=null,this.group=null,this.type="relationship",this.handles.add([t((()=>({feature:this.feature,element:this.element,layer:this.layer})),(e=>this._createRelationshipVM(e)),r)])}destroy(){this._relationshipVM?.destroy()}get canAddRelatedFeature(){const{editable:e,featureCount:t,_relationshipVM:r}=this;if(!r?.relationship||!this.loaded)return!1;const{cardinality:s,role:o}=r.relationship;return!("one-to-one"===s&&t>0)&&("many-to-many"!==s&&(!("one-to-many"===s&&"destination"===o&&t>0)&&e))}get displayCount(){return this.element.displayCount??n}get displayType(){return this.element.displayType}get editable(){return!!this.layerAllowsEdits&&(this.evaluatedEditableExpression??!0)}get featureCount(){return this._relationshipVM?.featureCount??0}get map(){return this._get("map")}set map(e){e&&this._relationshipVM?.set("map",e),this._set("map",e)}get orderByFields(){return this.element.orderByFields}get relationshipId(){return this.element.relationshipId}get relatedFeatureInfos(){return this._relationshipVM?.relatedFeatureInfos??[]}get relatedLayer(){return this._relationshipVM?.relatedLayer}get showAllEnabled(){return this._get("showAllEnabled")}set showAllEnabled(e){this._relationshipVM?.set("showAllEnabled",e),this._set("showAllEnabled",e)}get showAllActionVisible(){return!this.showAllEnabled&&this.featureCount>0&&this.featureCount>this.displayCount}get updating(){return"loading"===this._relationshipVM?.state||"querying"===this._relationshipVM?.state}get loaded(){return"ready"===this._relationshipVM?.state}incrementPage(){this._relationshipVM&&this._relationshipVM.featurePage++}getRelatedFeatureByObjectId(e){return this._relationshipVM?.getRelatedFeatureByObjectId(e)}_createRelationshipVM(e){const{feature:t,element:r,layer:s}=e;if(this._relationshipVM?.destroy(),!t||!r||!s)return;const{displayCount:o,map:a,orderByFields:n,relationshipId:p,showAllEnabled:u}=this;l(s)&&(this._relationshipVM=new i({graphic:t,displayCount:o,layer:s,map:a,orderByFields:n,relationshipId:p,showAllEnabled:u}))}};e([s()],p.prototype,"canAddRelatedFeature",null),e([s()],p.prototype,"displayCount",null),e([s()],p.prototype,"displayType",null),e([s()],p.prototype,"editable",null),e([s()],p.prototype,"group",void 0),e([s()],p.prototype,"map",null),e([s()],p.prototype,"orderByFields",null),e([s()],p.prototype,"relationshipId",null),e([s()],p.prototype,"relatedFeatureInfos",null),e([s()],p.prototype,"relatedLayer",null),e([s()],p.prototype,"showAllEnabled",null),e([s()],p.prototype,"showAllActionVisible",null),e([s({readOnly:!0})],p.prototype,"type",void 0),e([s()],p.prototype,"updating",null),e([s()],p.prototype,"incrementPage",null),e([s()],p.prototype,"getRelatedFeatureByObjectId",null),p=e([o("esri.widgets.FeatureForm.RelationshipInput")],p);const u=p;export{u as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- const e="esri-feature-form",i=`${e}__group`,t=`${e}__input`,r={base:e,form:`${e}__form`,formHeader:`${e}__form-header`,label:`${e}__label`,fieldInputWrapper:`${t}-wrapper`,fieldInputLoader:`${t}-loader`,fieldInput:`${t}`,inputDate:`${t}--date`,inputTime:`${t}--time`,inputRadioGroup:`${t}--radio-group`,inputRadio:`${t}--radio`,inputRadioLabel:`${t}--radio-label`,inputDisabled:`${t}--disabled`,inputSwitch:`${t}--switch`,inputInvalid:`${t}--invalid`,centeredButton:`${e}__centered-button`,description:`${e}__description-text`,listObserver:`${e}__list-observer`,relatedRecordList:`${e}__related-record-list`,dateInputContainer:`${`${e}__date`}-input-container`,group:i,groupLabel:`${i}-label`,groupHeader:`${i}-header`,groupTitle:`${i}-title`,groupToggleIcon:`${i}-toggle-icon`,groupCollapsed:`${i}--collapsed`,groupSequential:`${i}--sequential`,groupActive:`${i}--active`,collapseIcon:"esri-icon-up",expandIcon:"esri-icon-down",widget:"esri-widget",panel:"esri-widget--panel",input:"esri-input"};export{r as CSS};
5
+ const e="esri-feature-form",i=`${e}__group`,r=`${e}__input`,t=`${e}__related-records`,a={base:e,form:`${e}__form`,formHeader:`${e}__form-header`,label:`${e}__label`,relationshipLabel:`${e}__relationship-label`,fieldInputWrapper:`${r}-wrapper`,fieldInputLoader:`${r}-loader`,fieldInput:`${r}`,inputDate:`${r}--date`,inputTime:`${r}--time`,inputRadioGroup:`${r}--radio-group`,inputRadio:`${r}--radio`,inputRadioLabel:`${r}--radio-label`,inputDisabled:`${r}--disabled`,inputSwitch:`${r}--switch`,inputInvalid:`${r}--invalid`,centeredButton:`${e}__centered-button`,description:`${e}__description-text`,listObserver:`${e}__list-observer`,relatedRecordsHeader:`${t}_header`,relatedRecordsList:`${t}_list`,dateInputContainer:`${`${e}__date`}-input-container`,group:i,groupLabel:`${i}-label`,groupHeader:`${i}-header`,groupTitle:`${i}-title`,groupToggleIcon:`${i}-toggle-icon`,groupCollapsed:`${i}--collapsed`,groupSequential:`${i}--sequential`,groupActive:`${i}--active`,collapseIcon:"esri-icon-up",expandIcon:"esri-icon-down",widget:"esri-widget",panel:"esri-widget--panel",input:"esri-input"};export{a as CSS};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{neverReached as i}from"../core/compilerUtils.js";import{deprecatedProperty as l}from"../core/deprecate.js";import s from"../core/Logger.js";import{watch as a}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import{CSS as d}from"./FeatureForm/css.js";import{isGroupInput as u,isFieldInput as c,isRelationshipInput as p,isInputInGroupInput as m,isFieldElementWithInputType as h,formatDateFieldValue as v,getErrorMessageForFieldInput as _,getIconForFeature as b,isNumberFieldInput as g}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as y}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as w}from"./support/decorators/messageBundle.js";import{vmEvent as R}from"./support/decorators/vmEvent.js";import{tsx as C}from"./support/jsxFactory.js";import{DateTime as V}from"luxon";import{substitute as M}from"../intl/substitute.js";import{getLocale as D}from"../intl/locale.js";const O="TT",k="data-field-name",T="latn",x=e=>"valueAsDate"in e,N="esri.widgets.FeatureForm",L=s.getLogger(N);let j=class extends o{constructor(e,t){super(e,t),this._dateFieldInputMap=new Map,this._activeInputName="",this._activeNumberFieldEdit=null,this._fieldFocusNeeded=!1,this._fieldToInitialIncompatibleDomainValue=new Map,this._switchFieldsWithInitialIncompatibleValue=new Set,this._userUpdatedFieldInputNames=new Set,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.addRelatedRecord&&i.addRelatedRecord({parentFeature:t,relationshipId:e})},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([a((()=>this.feature),(()=>{const e=this._getFocusableInput("forward");this._activeInputName=e?.name||"",this._userUpdatedFieldInputNames.clear(),this._fieldToInitialIncompatibleDomainValue.clear(),this._switchFieldsWithInitialIncompatibleValue.clear(),this._dateFieldInputMap.clear(),this._fieldFocusNeeded=!0})),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._userUpdatedFieldInputNames.add(e))),this._activeInputName=t,this._fieldFocusNeeded=!0,this.scheduleRender()}})),a((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return I({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}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 map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=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 l(L,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){l(L,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return C("div",{class:this.classes(d.base,d.widget,d.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return C("form",{class:d.form,novalidate:!0,onsubmit:this._handleSubmit,onkeydown:this._handleFormKeyDown},this._renderHeader(),this._renderInputs())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&C(F,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&C("p",{class:d.description,key:"description"},e.formDescription);return C("div",{class:d.formHeader},t,i)}_renderInputs(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>u(e)?this._renderGroup(e,t):c(e)?this._renderLabeledField(e):p(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:C("div",{class:this.classes(d.description),id:t},e)}_renderGroup(e,t){const{formTemplate:i,disabled:l}=this,{description:s,inputs:a,label:n,state:r}=e,o=a.filter((e=>e.visible)),u=this.viewModel.findField(this._activeInputName),m=!(!u||u.group!==e),h=`${this.id}_group_${t}`,v=`${this.id}_group-label_${t}`,_=`${this.id}_group-description_${t}`,b=this._renderDescriptionOrEmpty(s,_),g="sequential"===this.groupDisplay,f=g?m:"expanded"===r,I=f?d.collapseIcon:d.expandIcon;return C("fieldset",{"aria-expanded":f.toString(),"aria-labelledby":v,"aria-describedby":s?_:"",class:this.classes(d.group,g?d.groupSequential:null,f?null:d.groupCollapsed,m?d.groupActive:null,l?d.inputDisabled:null),disabled:l,"data-group":e,id:h,key:t,onclick:this._handleGroupClick},C("button",{role:g?"presentation":void 0,class:d.groupHeader,type:"button",tabIndex:g?-1:0},C("div",{class:d.groupTitle},C(F,{class:d.groupLabel,id:v,level:null!=i&&i.title?y(this.headingLevel):this.headingLevel},n),b),g?null:C("span",{class:this.classes(I,d.groupToggleIcon)})),o.map((e=>c(e)?this._renderLabeledField(e):p(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,l="forward"===e?i:i.slice().reverse();let s;if(!t||p(t))s=0;else if(u(t)){const e=t.inputs.find(c);s=e?l.indexOf(e):0}else{let i;if(m(t)&&"collapsed"===t.group.state){const l=t.group.inputs.filter(c);i="forward"===e?l[l.length-1]:l[0]}else i=t;s=l.indexOf(i)+1}for(let a=s;a<l.length;a++){const e=l[a];if(e.visible&&c(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:l,layer:s}=e;return C("label",{key:`${s.id}-${i.uid}-${e.name}`,class:d.label},[l,"unsupported"!==t?this._renderFieldInput(e):this._renderUnsupportedField(e),this._renderAuxiliaryText(e)])}_renderFieldInput(e){const{dataType:t,domain:i,name:l,updating:s,value:a}=e,n=this.getCommonInputProps(e);if("coded-value"===i?.type){if(h(e.element,"switch")){const{element:t}=e;if(!(this._switchFieldsWithInitialIncompatibleValue.has(l)||null==a||t.input.onValue!==a&&t.input.offValue!==a))return this._renderSwitchFieldInput(e,n);this._switchFieldsWithInitialIncompatibleValue.add(l)}return"radio-buttons"===e.inputType?this._renderRadioButtonsFieldInput(e,i.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),n):this._renderSelectFieldInput(e,this._getFieldValueOptions(l,i),n)}if("datetime-picker"===e.inputType||"date"===t)return this._renderDateFieldInput(e,n);const r="number"===t?C("input",{type:"number",...n,value:null!=this._activeNumberFieldEdit&&this._activeNumberFieldEdit.fieldName===e.name?this._activeNumberFieldEdit.value:`${n.value}`}):"text-area"===e.inputType?C("textarea",{...n}):C("input",{type:"text",...n});return s?C("div",{key:`${n.key}-input-updating-wrapper`,class:d.fieldInputWrapper},r,C("div",{class:d.fieldInputLoader},C("calcite-progress",{type:"indeterminate"}))):r}_renderDateFieldInput(e,t){const{dateDataType:i,includeTime:l,label:s,name:a,valid:n,value:r}=e,{readOnly:o,required:u}=t;if("string"===i)return this._renderUnsupportedField(e,v(e.field,t.value));const{date:c,time:p}=this._formatValueForDateInputs(r),m=null!=t.max?this._formatValueForDateInputs(t.max):void 0,h=null!=t.min?this._formatValueForDateInputs(t.min):void 0,_=m?.date??void 0,b=h?.date??void 0,g={afterCreate:this._afterDateInputCreate,afterUpdate:this._afterDateInputCreateOrUpdate,"aria-invalid":!n,label:s,numberingSystem:T,overlayPositioning:"fixed",readOnly:o,required:u,tabIndex:0,[k]:a};return C("div",{key:`${t.key}-date-time-container`,class:d.dateInputContainer},C("calcite-input-date-picker",{bind:this,...g,class:this.classes(t.class,d.inputDate),"data-date-part":"date",key:`${t.key}-date-input`,valueAsDate:c??void 0,maxAsDate:_,minAsDate:b,onCalciteInputDatePickerChange:e=>this._commitDateChanges(e.target),onblur:e=>this._commitDateChanges(e.target,!0)}),l?C("calcite-input-time-picker",{bind:this,...g,class:this.classes(t.class,d.inputTime),"data-date-part":"time",key:`${t.key}-time-input`,value:p??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,t){const i=this.getCommonInputProps(e);return C("input",{afterCreate:i.afterCreate,afterUpdate:i.afterUpdate,class:this.classes(d.input,d.fieldInput,d.inputDisabled),onfocus:i.onfocus,readOnly:!0,tabIndex:i.tabIndex,type:"text",value:null!=t?`${t}`:i.value,[k]:i[k]})}_renderSelectFieldInput(e,t,i){const{element:l,required:s,value:a}=e,{messages:n,messagesTemplates:r}=this,o=t.map((e=>e.map((e=>C("calcite-combobox-item",{value:`${e.value}`,textLabel:e.name,key:`#${e.value}`,selected:a===e.value}))))),[d,u]=o;this._registerIncompatibleValue(a,t.flat(),e,(e=>{u.unshift(C("calcite-combobox-item",{value:`${e}`,textLabel:`${e}`,key:"incompatible-option",readOnly:!0}))}));const c=u.length>0?[C("calcite-combobox-item-group",{key:"recommended",label:n.recommended},d),C("calcite-combobox-item-group",{key:"other",label:r.other},u)]:d,p=null==l,m=h(l,"combo-box"),v=p||m&&l.input?.showNoValueOption;if(!s&&v){const e="",t=m&&l.input.noValueOptionLabel||n.empty;c.unshift(C("calcite-combobox-item",{value:e,textLabel:n.empty,key:"empty-option"},t))}return C("calcite-combobox",{...i,selectionMode:"single",disabled:i.readOnly,allowCustomValues:!1,onCalciteComboboxChange:e=>this._handleOptionChange(e.target)},c)}_registerIncompatibleValue(e,t,i,l){const s=this._fieldToInitialIncompatibleDomainValue,a=s.has(i.name);(a||null!=e&&""!==e&&!t.some((t=>t.value===e)))&&(a||s.set(i.name,e),l?.(e))}_renderRadioButtonsFieldInput(e,t,i){const{element:l,name:s,required:a,value:n}=e,r=t.map((e=>this._renderRadioButton({key:e.name,label:e.name,name:s,value:e.value,selected:e.value===n,props:i})));this._registerIncompatibleValue(n,t,e);const o=null==l,u=h(l,"radio-buttons"),c=o||u&&l.input?.showNoValueOption;if(!a&&c){const e="",t=u&&l.input.noValueOptionLabel||this.messages.empty,a=n===e||null===n;r.unshift(this._renderRadioButton({key:"empty-option",label:t,name:s,value:e,selected:a,props:i}))}return C("div",{key:`${i.key}-radio`,class:d.inputRadioGroup},r)}_renderSwitchFieldInput(e,t){const{value:i}=e,l=!!h(e.element,"switch")&&i===e.element.input.onValue;return C("calcite-switch",{...t,class:d.inputSwitch,onCalciteSwitchChange:e=>this._commitInputValue(e.target),checked:l,disabled:t.readOnly})}_renderRadioButton({key:e,name:t,value:i,selected:l,label:s,props:a}){return C("label",{key:e,class:d.inputRadioLabel},C("input",{...a,class:d.inputRadio,name:t,type:"radio",value:i,checked:l,disabled:a.readOnly,onchange:e=>this._commitInputValue(e.target)}),s)}_renderAuxiliaryText(e){const t=this._userUpdatedFieldInputNames.has(e.name)&&!e.valid?_(e,this.messages):null!=this.viewModel.contingencyConstraintViolations.get(e.name)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=t?C("calcite-input-message",{status:"invalid",icon:!0},t):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:l}=e,{relatedRecordCallbacks:s}=this;if(!l||!s?.showAllRelatedRecords)return;const a=this.messages;return C("calcite-list-item",{description:M(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},C("calcite-icon",{slot:"content-end",scale:"s",icon:"list"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i}=e,{relatedRecordCallbacks:l}=this;if(t&&l?.addRelatedRecord)return C("calcite-button",{alignment:"center",appearance:"outline-fill",class:d.centeredButton,iconStart:"plus",key:`${i}-add-button`,round:!0,scale:"s",width:"half",onclick:()=>this._onAddRelatedRecordsClick(i)},this.messages.addRecord)}_renderRelatedRecordListItem(e,t){const{feature:i,description:l,title:s}=e,{feature:a,relatedRecordCallbacks:n}=this,r=()=>{n?.editRelatedRecord&&a&&n.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})};return C("calcite-list-item",{bind:this,description:l,label:s,key:`${t}-${i.uid}`,value:s,onclick:r},C("calcite-icon",{slot:"content-start",scale:"m",icon:b(i)}),C("calcite-icon",{slot:"content-end",scale:"s",icon:"chevron-right"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{relationshipId:t,relatedFeatureInfos:i,showAllEnabled:l}=e,s=l?null:e.label,a=l?null:this._renderDescriptionOrEmpty(e.description),n=i.map((e=>this._renderRelatedRecordListItem(e,t)));return C("div",{class:d.label,key:`${s}-${t}`},C("calcite-label",null,s,a,C("calcite-list",{loading:e.updating,class:d.relatedRecordList},n,this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())),this._renderAddRelatedRecordButton(e))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return C("div",{key:"feature-observer",class:d.listObserver,bind:this,afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved})}getCommonInputProps(e){const{disabled:t,groupDisplay:i}=this,{dataType:l,editable:s,group:a,hint:n,label:r,maxLength:o,minLength:u,name:c,required:p,valid:m,value:h}=e,v=this._userUpdatedFieldInputNames.has(c),_=!s||t,b="all"===i&&null!=a&&"collapsed"===a.state;return{afterCreate:this._afterInputCreateOrUpdate,afterUpdate:this._afterInputCreateOrUpdate,"aria-invalid":m?"false":"true",class:this.classes(d.input,d.fieldInput,_?d.inputDisabled:null,v&&!m?d.inputInvalid:null),key:c,label:r,minlength:u>-1?`${u}`:"",maxlength:o>-1?`${o}`:"",...e.range,readOnly:_,value:null==h?"":`${h}`,[k]:c,onfocus:this._handleInputFocus,oninput:this._handleInputInput,onblur:this._handleInputBlur,onkeydown:this._handleInputKeyDown,onmousedown:"number"===l?this._handleNumberInputMouseDown:void 0,placeholder:"number"===l||"text"===l?n??void 0:"",required:p,tabIndex:b?-1:0}}_handleNumberInputMouseDown({target:e}){e.focus(),this.scheduleRender()}_getFieldValueOptions(e,t){const i=t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),l=this.viewModel.fieldsWithContingentValues.has(e)?this._getContingentValueOptions(e):[];if(l.length>0){const e=new Set(l.map((e=>e.value)));return[l,i.filter((t=>!e.has(t.value)))]}return[i,[]]}_getContingentValueOptions(e){const t={};for(const s of this.viewModel.allFieldInputs){const{name:i,value:l}=s;null!=l&&i!==e&&this.viewModel.fieldsWithContingentValues.has(i)&&(t[i]=l)}const i=this.viewModel.joinedContingentValues.slice(),l=new Map;for(const s of i){const i=s.values[e];if(null==i||"code"!==i.objectType&&"null"!==i.objectType)continue;const{code:a,name:n}=i.codedValue&&"null"!==i.objectType?i.codedValue:{code:"",name:this.messages.empty};if(l.has(a))continue;Object.entries(t).every((([e,t])=>!s.values.hasOwnProperty(e)||this._valueIsValidContingentValue(t,s.values[e])))&&l.set(a,{name:n,value:a})}return[...l.values()]}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(k))}async _afterDateInputCreate(e){!x(e)&&null!=e.value&&"setValue"in e&&e.setValue({value:e.value,origin:"external"}),this._afterDateInputCreateOrUpdate(e)}_afterDateInputCreateOrUpdate(e){const{name:t}=this._getFieldInputFromHTMLElement(e),i=this._dateFieldInputMap.get(t),l=x(e);null!=i?l?i.date=e:i.time=e:this._dateFieldInputMap.set(t,{[l?"date":"time"]:e}),this._afterInputCreateOrUpdate(e)}_afterInputCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),l=t.findField(this._activeInputName),s=this._fieldToInitialIncompatibleDomainValue.get(i.name)===i.value;this._fieldFocusNeeded&&l===i&&("radio-buttons"!==i.inputType||s||e.checked)&&(this._fieldFocusNeeded=!1,m(i)&&(i.group.state="expanded"),e.focus())}_handleInputFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._activeInputName=i.name,g(i)&&(this._activeNumberFieldEdit={fieldName:i.name,input:t,value:t.value})}_handleInputBlur(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);"number"===i.dataType&&null!=this._activeNumberFieldEdit&&(this._activeNumberFieldEdit.input.value=`${i.value}`,this._activeNumberFieldEdit=null),this._commitInputValue(t),this.scheduleRender()}_commitDateChanges(e,t=!1){const{name:i}=this._getFieldInputFromHTMLElement(e);if(!this._dateFieldInputMap.has(i))return;const l=this._dateFieldInputMap.get(i);if(!l||!l.date)return;const s=this._getFieldValueFromDateInput(e),a=this._getFieldValueFromDateInputs(l.date,l.time);this.viewModel.getValue(i)!==a&&(null!==s&&null!==a?this._updateFieldValue(i,a):t&&this._updateFieldValue(i,null))}_commitInputValue(e){const t=this._getFieldInputFromHTMLElement(e);null!=this._activeNumberFieldEdit&&g(t)&&(this._activeNumberFieldEdit.value=e.value),this._updateFieldValue(t.name,this._parseValue(e))}_handleInputKeyDown(e){const{key:t,altKey:i,ctrlKey:l,metaKey:s}=e,a=this._getFieldInputFromHTMLElement(e.target);if("Enter"===t)m(a)&&"collapsed"===a.group.state&&(a.group.state="expanded");else{const{type:n}=a.field,r="single"===n||"double"===n;if(("integer"===n||"small-integer"===n||r)&&(!i&&!l&&!s)&&1===t.length){const i=Number(t),l=["-","+"],s=["e","."],a=r?[...l,...s]:l;isNaN(i)&&!a.includes(t)&&e.preventDefault()}}}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._userUpdatedFieldInputNames.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;if(h(t.element,"switch")&&"CALCITE-COMBOBOX"!==e.tagName)return e.checked?t.element.input.onValue:t.element.input.offValue;if("radio-buttons"===t.inputType&&"radio"===e.type&&!e.checked)return t.value;const{dataType:l}=t;return"number"===l?i?parseFloat(i):null:i}_handleOptionChange(e){this._commitInputValue(e),this.scheduleRender()}_handleGroupClick(e){const t=e.currentTarget["data-group"],i="expanded"===t.state,l="sequential"===this.groupDisplay,s=`.${d.groupHeader}`;if(!(i&&!e.target.closest(s))){if(this._activeInputName=this._getFocusableInput("forward",t)?.name||"",l){const l=e.target.closest(s);if(i&&!l)return;this.viewModel.inputs.forEach((e=>{u(e)&&e!==t&&(e.state="collapsed")}))}t.state=i?"collapsed":"expanded",this._fieldFocusNeeded=l,this.scheduleRender()}}_handleSubmit(e){e.preventDefault()}_handleFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_getDefaultLocaleOptions(){return{locale:D(),numberingSystem:T}}_getFieldValueFromDateInputs(e,t){const i=this._getDateTimeFromInput(e),l=this._getDateTimeFromInput(t);if(!i&&!l)return null;const s=this._getFieldInputFromHTMLElement(e).range,a=Date.now(),n=null!=s.max&&s.max<a?s.max:a,r=V.fromMillis(n,this._getDefaultLocaleOptions()),o=i||r,{year:d,month:u,day:c}=o,{hour:p,minute:m,second:h}=l||r,v=o.set({year:d,month:u,day:c,hour:p,minute:m,second:h});return v.isValid?v.toMillis():null}_getDateTimeFromInput(e){if(!e)return null;let t=null;if(x(e)){const i=e.valueAsDate;if(!i||Array.isArray(i))return null;t=V.fromJSDate(i)}else{if(!e.value)return null;t=V.fromFormat(e.value,O,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:V.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(O,this._getDefaultLocaleOptions())}:{date:null,time:null}}_valueIsValidContingentValue(e,t){switch(t.objectType){case"any":return!0;case"null":return null==e;case"code":return e===t.codedValue?.code;case"range":return null!=e&&null!=t.minValue&&null!=t.maxValue&&+e>=t.minValue&&+e<=t.maxValue;default:return i(t.objectType),!1}}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}async _onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;if(!e)return;const{showAllEnabled:t,updating:i}=e;this._listObserverNode&&!i&&t&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}};e([n()],j.prototype,"_listObserverNode",void 0),e([n()],j.prototype,"_relatedRecordsEnabled",null),e([n()],j.prototype,"disabled",null),e([n()],j.prototype,"feature",null),e([n()],j.prototype,"formTemplate",null),e([n()],j.prototype,"groupDisplay",void 0),e([n()],j.prototype,"headingLevel",void 0),e([n()],j.prototype,"label",null),e([n()],j.prototype,"layer",null),e([n()],j.prototype,"map",null),e([n(),w("esri/widgets/FeatureForm/t9n/FeatureForm")],j.prototype,"messages",void 0),e([n(),w("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],j.prototype,"messagesTemplates",void 0),e([n()],j.prototype,"relatedRecordCallbacks",null),e([n()],j.prototype,"relationshipId",null),e([n()],j.prototype,"spatialReference",null),e([n()],j.prototype,"strict",null),e([n()],j.prototype,"view",null),e([n(),R(["value-change","submit"])],j.prototype,"viewModel",void 0),j=e([r(N)],j);const E=j;export{E as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{neverReached as i}from"../core/compilerUtils.js";import{deprecatedProperty as s}from"../core/deprecate.js";import a from"../core/Logger.js";import{watch as l}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import{CSS as d}from"./FeatureForm/css.js";import{isGroupInput as u,isFieldInput as c,isRelationshipInput as p,isInputInGroupInput as m,isFieldElementWithInputType as h,formatDateFieldValue as v,getErrorMessageForFieldInput as _,getIconForFeature as b,isNumberFieldInput as g}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as y}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as w}from"./support/decorators/messageBundle.js";import{vmEvent as R}from"./support/decorators/vmEvent.js";import{tsx as C}from"./support/jsxFactory.js";import{DateTime as M}from"luxon";import{substitute as V}from"../intl/substitute.js";import{getLocale as D}from"../intl/locale.js";const k="TT",O="data-field-name",T="latn",x=e=>"valueAsDate"in e,N="esri.widgets.FeatureForm",L=a.getLogger(N);let j=class extends o{constructor(e,t){super(e,t),this._dateFieldInputMap=new Map,this._activeInputName="",this._activeNumberFieldEdit=null,this._fieldFocusNeeded=!1,this._fieldToInitialIncompatibleDomainValue=new Map,this._switchFieldsWithInitialIncompatibleValue=new Set,this._userUpdatedFieldInputNames=new Set,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:s}=this;i&&s?.addRelatedRecord&&s.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},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([l((()=>this.feature),(()=>{const e=this._getFocusableInput("forward");this._activeInputName=e?.name||"",this._userUpdatedFieldInputNames.clear(),this._fieldToInitialIncompatibleDomainValue.clear(),this._switchFieldsWithInitialIncompatibleValue.clear(),this._dateFieldInputMap.clear(),this._fieldFocusNeeded=!0})),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._userUpdatedFieldInputNames.add(e))),this._activeInputName=t,this._fieldFocusNeeded=!0,this.scheduleRender()}})),l((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return I({button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}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 map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=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 s(L,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){s(L,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return C("div",{class:this.classes(d.base,d.widget,d.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return C("form",{class:d.form,novalidate:!0,onsubmit:this._handleSubmit,onkeydown:this._handleFormKeyDown},this._renderHeader(),this._renderInputs())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&C(F,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&C("p",{class:d.description,key:"description"},e.formDescription);return C("div",{class:d.formHeader},t,i)}_renderInputs(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>u(e)?this._renderGroup(e,t):c(e)?this._renderLabeledField(e):p(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:C("div",{class:this.classes(d.description),id:t},e)}_renderGroup(e,t){const{formTemplate:i,disabled:s}=this,{description:a,inputs:l,label:n,state:r}=e,o=l.filter((e=>e.visible)),u=this.viewModel.findField(this._activeInputName),m=!(!u||u.group!==e),h=`${this.id}_group_${t}`,v=`${this.id}_group-label_${t}`,_=`${this.id}_group-description_${t}`,b=this._renderDescriptionOrEmpty(a,_),g="sequential"===this.groupDisplay,f=g?m:"expanded"===r,I=f?d.collapseIcon:d.expandIcon;return C("fieldset",{"aria-expanded":f.toString(),"aria-labelledby":v,"aria-describedby":a?_:"",class:this.classes(d.group,g?d.groupSequential:null,f?null:d.groupCollapsed,m?d.groupActive:null,s?d.inputDisabled:null),disabled:s,"data-group":e,id:h,key:t,onclick:this._handleGroupClick},C("button",{role:g?"presentation":void 0,class:d.groupHeader,type:"button",tabIndex:g?-1:0},C("div",{class:d.groupTitle},C(F,{class:d.groupLabel,id:v,level:null!=i&&i.title?y(this.headingLevel):this.headingLevel},n),b),g?null:C("span",{class:this.classes(I,d.groupToggleIcon)})),o.map((e=>c(e)?this._renderLabeledField(e):p(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,s="forward"===e?i:i.slice().reverse();let a;if(!t||p(t))a=0;else if(u(t)){const e=t.inputs.find(c);a=e?s.indexOf(e):0}else{let i;if(m(t)&&"collapsed"===t.group.state){const s=t.group.inputs.filter(c);i="forward"===e?s[s.length-1]:s[0]}else i=t;a=s.indexOf(i)+1}for(let l=a;l<s.length;l++){const e=s[l];if(e.visible&&c(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:s,layer:a}=e;return C("label",{key:`${a.id}-${i.uid}-${e.name}`,class:d.label},[s,"unsupported"!==t?this._renderFieldInput(e):this._renderUnsupportedField(e),this._renderAuxiliaryText(e)])}_renderFieldInput(e){const{dataType:t,domain:i,name:s,updating:a,value:l}=e,n=this.getCommonInputProps(e);if("coded-value"===i?.type){if(h(e.element,"switch")){const{element:t}=e;if(!(this._switchFieldsWithInitialIncompatibleValue.has(s)||null==l||t.input.onValue!==l&&t.input.offValue!==l))return this._renderSwitchFieldInput(e,n);this._switchFieldsWithInitialIncompatibleValue.add(s)}return"radio-buttons"===e.inputType?this._renderRadioButtonsFieldInput(e,i.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),n):this._renderSelectFieldInput(e,this._getFieldValueOptions(s,i),n)}if("datetime-picker"===e.inputType||"date"===t)return this._renderDateFieldInput(e,n);const r="number"===t?C("input",{type:"number",...n,value:null!=this._activeNumberFieldEdit&&this._activeNumberFieldEdit.fieldName===e.name?this._activeNumberFieldEdit.value:`${n.value}`}):"text-area"===e.inputType?C("textarea",{...n}):C("input",{type:"text",...n});return a?C("div",{key:`${n.key}-input-updating-wrapper`,class:d.fieldInputWrapper},r,C("div",{class:d.fieldInputLoader},C("calcite-progress",{type:"indeterminate"}))):r}_renderDateFieldInput(e,t){const{dateDataType:i,includeTime:s,label:a,name:l,valid:n,value:r}=e,{readOnly:o,required:u}=t;if("string"===i)return this._renderUnsupportedField(e,v(e.field,t.value));const{date:c,time:p}=this._formatValueForDateInputs(r),m=null!=t.max?this._formatValueForDateInputs(t.max):void 0,h=null!=t.min?this._formatValueForDateInputs(t.min):void 0,_=m?.date??void 0,b=h?.date??void 0,g={afterCreate:this._afterDateInputCreate,afterUpdate:this._afterDateInputCreateOrUpdate,"aria-invalid":!n,label:a,numberingSystem:T,overlayPositioning:"fixed",readOnly:o,required:u,tabIndex:0,[O]:l};return C("div",{key:`${t.key}-date-time-container`,class:d.dateInputContainer},C("calcite-input-date-picker",{bind:this,...g,class:this.classes(t.class,d.inputDate),"data-date-part":"date",key:`${t.key}-date-input`,valueAsDate:c??void 0,maxAsDate:_,minAsDate:b,onCalciteInputDatePickerChange:e=>this._commitDateChanges(e.target),onblur:e=>this._commitDateChanges(e.target,!0)}),s?C("calcite-input-time-picker",{bind:this,...g,class:this.classes(t.class,d.inputTime),"data-date-part":"time",key:`${t.key}-time-input`,value:p??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,t){const i=this.getCommonInputProps(e);return C("input",{afterCreate:i.afterCreate,afterUpdate:i.afterUpdate,class:this.classes(d.input,d.fieldInput,d.inputDisabled),onfocus:i.onfocus,readOnly:!0,tabIndex:i.tabIndex,type:"text",value:null!=t?`${t}`:i.value,[O]:i[O]})}_renderSelectFieldInput(e,t,i){const{element:s,required:a,value:l}=e,{messages:n,messagesTemplates:r}=this,o=t.map((e=>e.map((e=>C("calcite-combobox-item",{value:`${e.value}`,textLabel:e.name,key:`#${e.value}`,selected:l===e.value}))))),[d,u]=o;this._registerIncompatibleValue(l,t.flat(),e,(e=>{u.unshift(C("calcite-combobox-item",{value:`${e}`,textLabel:`${e}`,key:"incompatible-option",readOnly:!0}))}));const c=u.length>0?[C("calcite-combobox-item-group",{key:"recommended",label:n.recommended},d),C("calcite-combobox-item-group",{key:"other",label:r.other},u)]:d,p=null==s,m=h(s,"combo-box"),v=p||m&&s.input?.showNoValueOption;if(!a&&v){const e="",t=m&&s.input.noValueOptionLabel||n.empty;c.unshift(C("calcite-combobox-item",{value:e,textLabel:n.empty,key:"empty-option"},t))}return C("calcite-combobox",{...i,selectionMode:"single",disabled:i.readOnly,allowCustomValues:!1,onCalciteComboboxChange:e=>this._handleOptionChange(e.target)},c)}_registerIncompatibleValue(e,t,i,s){const a=this._fieldToInitialIncompatibleDomainValue,l=a.has(i.name);(l||null!=e&&""!==e&&!t.some((t=>t.value===e)))&&(l||a.set(i.name,e),s?.(e))}_renderRadioButtonsFieldInput(e,t,i){const{element:s,name:a,required:l,value:n}=e,r=t.map((e=>this._renderRadioButton({key:e.name,label:e.name,name:a,value:e.value,selected:e.value===n,props:i})));this._registerIncompatibleValue(n,t,e);const o=null==s,u=h(s,"radio-buttons"),c=o||u&&s.input?.showNoValueOption;if(!l&&c){const e="",t=u&&s.input.noValueOptionLabel||this.messages.empty,l=n===e||null===n;r.unshift(this._renderRadioButton({key:"empty-option",label:t,name:a,value:e,selected:l,props:i}))}return C("div",{key:`${i.key}-radio`,class:d.inputRadioGroup},r)}_renderSwitchFieldInput(e,t){const{value:i}=e,s=!!h(e.element,"switch")&&i===e.element.input.onValue;return C("calcite-switch",{...t,class:d.inputSwitch,onCalciteSwitchChange:e=>this._commitInputValue(e.target),checked:s,disabled:t.readOnly})}_renderRadioButton({key:e,name:t,value:i,selected:s,label:a,props:l}){return C("label",{key:e,class:d.inputRadioLabel},C("input",{...l,class:d.inputRadio,name:t,type:"radio",value:i,checked:s,disabled:l.readOnly,onchange:e=>this._commitInputValue(e.target)}),a)}_renderAuxiliaryText(e){const t=this._userUpdatedFieldInputNames.has(e.name)&&!e.valid?_(e,this.messages):null!=this.viewModel.contingencyConstraintViolations.get(e.name)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=t?C("calcite-input-message",{status:"invalid",icon:!0},t):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:s}=e,{relatedRecordCallbacks:a}=this;if(!s||!a?.showAllRelatedRecords)return;const l=this.messages;return C("calcite-list-item",{description:V(l.totalCount,{count:t}),label:l.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},C("calcite-icon",{slot:"content-end",scale:"s",icon:"list"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:s}=e,{relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&s)return C("calcite-button",{alignment:"center",appearance:"outline-fill",class:d.centeredButton,disabled:e.updating,iconStart:"plus",key:`${i}-add-button`,round:!0,scale:"s",width:"half",onclick:()=>this._onAddRelatedRecordsClick(i,s)},this.messages.addRecord)}_renderRelatedRecordListItem(e,t){const{feature:i,description:s,title:a}=e,{feature:l,relatedRecordCallbacks:n}=this,r=()=>{n?.editRelatedRecord&&l&&n.editRelatedRecord({parentFeature:l,relationshipId:t,relatedFeature:i})};return C("calcite-list-item",{bind:this,description:s,label:a,key:`${t}-${i.uid}`,value:a,onclick:r},C("calcite-icon",{slot:"content-start",scale:"m",icon:b(i)}),C("calcite-icon",{slot:"content-end",scale:"s",icon:"chevron-right"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{relationshipId:t,relatedFeatureInfos:i,showAllEnabled:s}=e,a=s?null:this._renderDescriptionOrEmpty(e.description),l=i.length?this._renderRelatedRecordsList(e):e.loaded?this._renderNoRelatedRecordsNotice():void 0;return C("label",{class:this.classes(d.label,d.relationshipLabel),key:`relationship-${t}-container`},C("div",null,this._renderRelatedRecordsHeaderContainer(e),a,l),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return C("div",{class:d.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},C("span",null,e.label),t?C("calcite-loader",{label:this.messagesCommon?.loading,inline:!0,key:"loader",scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return C("calcite-list",{class:d.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoRelatedRecordsNotice(){return C("calcite-notice",{open:!0,scale:"s",kind:"brand",icon:"information",width:"full"},C("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return C("div",{key:"feature-observer",class:d.listObserver,bind:this,afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved})}getCommonInputProps(e){const{disabled:t,groupDisplay:i}=this,{dataType:s,editable:a,group:l,hint:n,label:r,maxLength:o,minLength:u,name:c,required:p,valid:m,value:h}=e,v=this._userUpdatedFieldInputNames.has(c),_=!a||t,b="all"===i&&null!=l&&"collapsed"===l.state;return{afterCreate:this._afterInputCreateOrUpdate,afterUpdate:this._afterInputCreateOrUpdate,"aria-invalid":m?"false":"true",class:this.classes(d.input,d.fieldInput,_?d.inputDisabled:null,v&&!m?d.inputInvalid:null),key:c,label:r,minlength:u>-1?`${u}`:"",maxlength:o>-1?`${o}`:"",...e.range,readOnly:_,value:null==h?"":`${h}`,[O]:c,onfocus:this._handleInputFocus,oninput:this._handleInputInput,onblur:this._handleInputBlur,onkeydown:this._handleInputKeyDown,onmousedown:"number"===s?this._handleNumberInputMouseDown:void 0,placeholder:"number"===s||"text"===s?n??void 0:"",required:p,tabIndex:b?-1:0}}_handleNumberInputMouseDown({target:e}){e.focus(),this.scheduleRender()}_getFieldValueOptions(e,t){const i=t.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),s=this.viewModel.fieldsWithContingentValues.has(e)?this._getContingentValueOptions(e):[];if(s.length>0){const e=new Set(s.map((e=>e.value)));return[s,i.filter((t=>!e.has(t.value)))]}return[i,[]]}_getContingentValueOptions(e){const t={};for(const a of this.viewModel.allFieldInputs){const{name:i,value:s}=a;null!=s&&i!==e&&this.viewModel.fieldsWithContingentValues.has(i)&&(t[i]=s)}const i=this.viewModel.joinedContingentValues.slice(),s=new Map;for(const a of i){const i=a.values[e];if(null==i||"code"!==i.objectType&&"null"!==i.objectType)continue;const{code:l,name:n}=i.codedValue&&"null"!==i.objectType?i.codedValue:{code:"",name:this.messages.empty};if(s.has(l))continue;Object.entries(t).every((([e,t])=>!a.values.hasOwnProperty(e)||this._valueIsValidContingentValue(t,a.values[e])))&&s.set(l,{name:n,value:l})}return[...s.values()]}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(O))}async _afterDateInputCreate(e){this._afterDateInputCreateOrUpdate(e)}_afterDateInputCreateOrUpdate(e){const{name:t}=this._getFieldInputFromHTMLElement(e),i=this._dateFieldInputMap.get(t),s=x(e);null!=i?s?i.date=e:i.time=e:this._dateFieldInputMap.set(t,{[s?"date":"time"]:e}),this._afterInputCreateOrUpdate(e)}_afterInputCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),s=t.findField(this._activeInputName),a=this._fieldToInitialIncompatibleDomainValue.get(i.name)===i.value;this._fieldFocusNeeded&&s===i&&("radio-buttons"!==i.inputType||a||e.checked)&&(this._fieldFocusNeeded=!1,m(i)&&(i.group.state="expanded"),e.focus())}_handleInputFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._activeInputName=i.name,g(i)&&(this._activeNumberFieldEdit={fieldName:i.name,input:t,value:t.value})}_handleInputBlur(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);"number"===i.dataType&&null!=this._activeNumberFieldEdit&&(this._activeNumberFieldEdit.input.value=`${i.value}`,this._activeNumberFieldEdit=null),this._commitInputValue(t),this.scheduleRender()}_commitDateChanges(e,t=!1){const{name:i}=this._getFieldInputFromHTMLElement(e);if(!this._dateFieldInputMap.has(i))return;const s=this._dateFieldInputMap.get(i);if(!s||!s.date)return;const a=this._getFieldValueFromDateInput(e),l=this._getFieldValueFromDateInputs(s.date,s.time);this.viewModel.getValue(i)!==l&&(null!==a&&null!==l?this._updateFieldValue(i,l):t&&this._updateFieldValue(i,null))}_commitInputValue(e){const t=this._getFieldInputFromHTMLElement(e);null!=this._activeNumberFieldEdit&&g(t)&&(this._activeNumberFieldEdit.value=e.value),this._updateFieldValue(t.name,this._parseValue(e))}_handleInputKeyDown(e){const{key:t,altKey:i,ctrlKey:s,metaKey:a}=e,l=this._getFieldInputFromHTMLElement(e.target);if("Enter"===t)m(l)&&"collapsed"===l.group.state&&(l.group.state="expanded");else{const{type:n}=l.field,r="single"===n||"double"===n;if(("integer"===n||"small-integer"===n||r)&&(!i&&!s&&!a)&&1===t.length){const i=Number(t),s=["-","+"],a=["e","."],l=r?[...s,...a]:s;isNaN(i)&&!l.includes(t)&&e.preventDefault()}}}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._userUpdatedFieldInputNames.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;if(h(t.element,"switch")&&"CALCITE-COMBOBOX"!==e.tagName)return e.checked?t.element.input.onValue:t.element.input.offValue;if("radio-buttons"===t.inputType&&"radio"===e.type&&!e.checked)return t.value;const{dataType:s}=t;return"number"===s?i?parseFloat(i):null:i}_handleOptionChange(e){this._commitInputValue(e),this.scheduleRender()}_handleGroupClick(e){const t=e.currentTarget["data-group"],i="expanded"===t.state,s="sequential"===this.groupDisplay,a=`.${d.groupHeader}`;if(!(i&&!e.target.closest(a))){if(this._activeInputName=this._getFocusableInput("forward",t)?.name||"",s){const s=e.target.closest(a);if(i&&!s)return;this.viewModel.inputs.forEach((e=>{u(e)&&e!==t&&(e.state="collapsed")}))}t.state=i?"collapsed":"expanded",this._fieldFocusNeeded=s,this.scheduleRender()}}_handleSubmit(e){e.preventDefault()}_handleFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_getDefaultLocaleOptions(){return{locale:D(),numberingSystem:T}}_getFieldValueFromDateInputs(e,t){const i=this._getDateTimeFromInput(e),s=this._getDateTimeFromInput(t);if(!i&&!s)return null;const a=this._getFieldInputFromHTMLElement(e).range,l=Date.now(),n=null!=a.max&&a.max<l?a.max:l,r=M.fromMillis(n,this._getDefaultLocaleOptions()),o=i||r,{year:d,month:u,day:c}=o,{hour:p,minute:m,second:h}=s||r,v=o.set({year:d,month:u,day:c,hour:p,minute:m,second:h});return v.isValid?v.toMillis():null}_getDateTimeFromInput(e){if(!e)return null;let t=null;if(x(e)){const i=e.valueAsDate;if(!i||Array.isArray(i))return null;t=M.fromJSDate(i)}else{if(!e.value)return null;t=M.fromFormat(e.value,k,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:M.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(k,this._getDefaultLocaleOptions())}:{date:null,time:null}}_valueIsValidContingentValue(e,t){switch(t.objectType){case"any":return!0;case"null":return null==e;case"code":return e===t.codedValue?.code;case"range":return null!=e&&null!=t.minValue&&null!=t.maxValue&&+e>=t.minValue&&+e<=t.maxValue;default:return i(t.objectType),!1}}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}async _onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;if(!e)return;const{showAllEnabled:t,updating:i}=e;this._listObserverNode&&!i&&t&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}};e([n()],j.prototype,"_listObserverNode",void 0),e([n()],j.prototype,"_relatedRecordsEnabled",null),e([n()],j.prototype,"disabled",null),e([n()],j.prototype,"feature",null),e([n()],j.prototype,"formTemplate",null),e([n()],j.prototype,"groupDisplay",void 0),e([n()],j.prototype,"headingLevel",void 0),e([n()],j.prototype,"label",null),e([n()],j.prototype,"layer",null),e([n()],j.prototype,"map",null),e([n(),w("esri/widgets/FeatureForm/t9n/FeatureForm")],j.prototype,"messages",void 0),e([n(),w("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([n(),w("esri/widgets/Feature/t9n/Feature")],j.prototype,"messagesFeature",void 0),e([n(),w("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],j.prototype,"messagesTemplates",void 0),e([n()],j.prototype,"relatedRecordCallbacks",null),e([n()],j.prototype,"relationshipId",null),e([n()],j.prototype,"spatialReference",null),e([n()],j.prototype,"strict",null),e([n()],j.prototype,"view",null),e([n(),R(["value-change","submit"])],j.prototype,"viewModel",void 0),j=e([r(N)],j);const E=j;export{E as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as o,convertDateFormatToIntlOptions as r}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as a,formatNumber as l}from"../../intl/number.js";import s from"../../layers/support/CodedValueDomain.js";import{isEditableLayer as u}from"../../layers/support/editableLayers.js";import{isNumericField as d,isStringField as p}from"../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as c}from"../../layers/support/layerUtils.js";import{unsupportedDateFieldTypes as m,formatDateFieldValue as h}from"../FeatureForm/featureFormUtils.js";import f from"../FeatureForm/FieldInput.js";import g from"./Grid/EditorColumn.js";import y from"../support/DatePicker.js";import v from"../support/TimePicker.js";import{renderingSanitizer as b}from"../support/widgetUtils.js";const F={cancelEdit:"Escape"},_="esri-field-column",C={headerContent:`${_}__header-content`,headerLabel:`${_}__header-label`,input:`${_}__cell-input`,inputContainer:`${_}__cell__input-container`,dateInputContainer:`${_}__cell__date-input-container`,dateInputWrapper:`${_}__cell__date-input-wrapper`,button:`${_}__button`,saveIcon:"esri-icon-save",trashIcon:"esri-icon-trash",locked:"esri-icon-locked"},E=r("short-date-short-time"),I=r("short-date"),L={useGrouping:!0,maximumFractionDigits:20};let D=class extends g{constructor(e){super(e),this._inputField=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{config:e,field:n}=this;return this.formatFunction({config:e,field:n,value:b.sanitize(t)})}if(null===t)return"&nbsp;";const{config:n,field:i}=this,r=e?.item?.feature,s=this._getDomainForFeature(r);if(s)return this._getComputedDomain(t,s);if("date"===i.type){const e=this._getDateFormatOptions(),n="feature"===this.layer?.type&&this.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null;return t?o(t,{...e,...n}):null}if(m.has(i.type)&&t){const e=h(i,t);return b.sanitize(e)}if(d(i)){const e=n?.format?a(n.format):L;return l(parseFloat(t),e)}return b.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:t})=>!(this._inputField&&!this._inputField.valid)&&((!this.required||null!=t&&""!==t)&&e!==t),this.config=null,this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:o,sortable:r}=this;if(this.removeCellContent(t),t.classList.add(C.headerContent),i&&!n&&t.appendChild(this.createLockedElement()),r)this.headerSorterRenderFunction(e);else{const e=document.createElement("div");e.classList.add(C.headerLabel),e.textContent=this.label,t.appendChild(e)}o&&this.headerMenuRenderFunction(e)},this.inputRenderFunction=({root:e,column:t,rowData:n})=>{if(this.activeEditInfo?.updating)return;if(!this.editable)return;const i=this.getCellValue(t,n),o=this.createInputElement({root:e,column:t,rowData:n,value:i});if(this._set("activeEditInfo",{column:t,input:o,root:e,rowData:n,updating:!0,oldValue:i}),"date"===this.field.type)return void this._renderDateEditors(i,e,o);const r=this.createInputContainer();r.appendChild(o),this.removeCellContent(e),e.appendChild(r),o.focus(),o instanceof HTMLInputElement&&o.select(),this.grid?.notifyResize()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._inputField;if(!t)return null;const n=e.value,{dataType:i,required:o}=t;return o||""!==n?"number"===i||"date"===i?parseFloat(n):"text"===i?n.trim():n:null},this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e&&(e.item.feature.attributes[t.path]=n)},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store)return;const i=e.item.objectId,o=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:o,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.config?.description??this.field?.description??null}get editable(){const{config:e,editingEnabled:t,field:n,layer:i,template:o}=this;if(null==n||null==i)return!1;const r=u(i),a=c(i),l=a?.operations.supportsUpdate;return!!(n.editable&&r&&l)&&(!m.has(n.type)&&(t?!(!1===o?.editable||!1===e?.editable):!(!o?.editable&&!e?.editable)))}get header(){return this.template?.label||this.config?.label||this.alias||this.path||null}get hidden(){const{config:e}=this;return!1===e?.visible||this._get("hidden")||!1}set hidden(e){this._set("hidden",e)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,config:t,template:n}=this,i=e?.length,o=n?.input&&"maxLength"in n.input?n.input.maxLength:t?.maxLength;return null!=o&&!isNaN(o)&&o>=-1&&(-1===i||o<=i)?o:i}get minLength(){const{config:e,template:t,maxLength:n}=this,i=t?.input&&"minLength"in t.input?t.input.minLength:e?.minLength||null;return n&&i<=n?i:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{config:e,field:t,template:n}=this,i=t?.nullable,o=e?.required,r=n?.required;return this.editable&&(!i||!0===o||!0===r)}get sortable(){return this.template?!1!==this.template?.sortable:!1!==this.config?.sortable}createInputElement({rowData:e,value:t}){const n=e?.item;if(!n||!n.feature)return null;this._inputField=this._setUpInputField(n.feature,t);const{field:i,maxLength:o,minLength:r,required:a}=this,{domain:l}=this._inputField;let s;"coded-value"===l?.type?(s=this._createSelectElement(t,l.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._inputField),s.onchange=()=>{s.onblur=null,p()}):(s=document.createElement("input"),s.type=d(i)?"number":"text",o>-1&&(s.maxLength=o),r>0&&(s.minLength=r)),s.classList.add(C.input),s.value=t,s.required=a;let u=!1;s.onkeydown=e=>{u=e.key===F.cancelEdit},s.onblur=()=>{s.onblur=null,p()};const p=()=>{u?this.cancel():this.submit(),this._inputField=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(C.inputContainer),e}createLockedElement(){const e=document.createElement("div");return e.classList.add(C.locked),e}getCellValue({path:e},t){return t?.item?.feature?.attributes?.[e]??null}_renderDateEditors(e,n,i){const{config:o,messagesCommon:r,template:a}=this,l=e?new Date(e):new Date(Date.now()),s=new y({dateInputEnabled:!0,value:l}),u=new v({value:l});i.value=l.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};t((()=>[s.value,u.value]),(()=>p()));const h=document.createElement("div"),f=document.createElement("div");s.container=h,u.container=f;const g=document.createElement("button");g.classList.add(C.button,C.saveIcon),g.onclick=()=>c(),g.title=r?.save;const b=document.createElement("button");b.classList.add(C.button,C.trashIcon),b.onclick=()=>m(),b.title=r?.clear;const F=document.createElement("div");F.classList.add(C.dateInputWrapper),F.appendChild(h),(a&&a.input&&"datetime-picker"===a.input.type&&!1!==a.input.includeTime||o&&!1!==o.includeTime)&&F.appendChild(f);const _=document.createElement("div");_.classList.add(C.dateInputContainer),_.appendChild(F),_.appendChild(g),_.appendChild(b),s.when((()=>this.grid?.notifyResize())),u.when((()=>this.grid?.notifyResize())),this.removeCellContent(n),n.appendChild(_),this.grid?.notifyResize()}_createSelectElement(e,t,n){let i=!1;const o=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,o.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",o.unshift(e)}const r=document.createElement("select");return o.forEach((e=>r.add(e))),r.value=e,r}_setUpInputField(e,t){const{field:n,layer:i}=this,o=new f({feature:e,initialFeature:e.clone(),field:n,layer:i});return o.set("value",t),o}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&p(t)||"number"===n&&d(t))return!0}return!(!e||"range"!==e.type||!d(t))}_getDomainForFeature(e){const{config:t,layer:n,name:i,template:o}=this;if(!n)return null;if("wfs"===n.type||"geojson"===n.type||"csv"===n.type)return null;if(o?.domain&&this._isDomainCompatible(o.domain))return o.domain;const{typeIdField:r}=n,a=r===i,l=this.field.domain;if(a&&!l)return new s({name:"__internal-type-based-coded-value-domain__",codedValues:n.types?.map((({id:e,name:t})=>({code:e,name:t})))});const u=r&&null!=i&&n.getFieldDomain(i,{feature:e})||l,d=t?.domain;return this._isDomainCompatible(d)?d:u}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{config:e,template:t}=this,n=t?.format?.dateFormat||e?.format?.dateFormat;return n?r(n):t&&t.input&&"includeTime"in t.input==!1||!1===e?.includeTime?I:E}};e([n({readOnly:!0})],D.prototype,"alias",null),e([n()],D.prototype,"cellValueFormatFunction",void 0),e([n()],D.prototype,"cellValueValidatorFunction",void 0),e([n()],D.prototype,"config",void 0),e([n({readOnly:!0})],D.prototype,"defaultValue",null),e([n({readOnly:!0})],D.prototype,"description",null),e([n({readOnly:!0})],D.prototype,"editable",null),e([n()],D.prototype,"editingEnabled",void 0),e([n()],D.prototype,"expressionInfos",void 0),e([n()],D.prototype,"field",void 0),e([n()],D.prototype,"formatFunction",void 0),e([n({readOnly:!0})],D.prototype,"header",null),e([n()],D.prototype,"hidden",null),e([n()],D.prototype,"headerRenderFunction",void 0),e([n()],D.prototype,"inputRenderFunction",void 0),e([n()],D.prototype,"layer",void 0),e([n({readOnly:!0})],D.prototype,"loadingMessage",null),e([n()],D.prototype,"maxLength",null),e([n()],D.prototype,"minLength",null),e([n({readOnly:!0})],D.prototype,"name",null),e([n({readOnly:!0})],D.prototype,"nullable",null),e([n()],D.prototype,"parseInputValueFunction",void 0),e([n({readOnly:!0})],D.prototype,"path",null),e([n({readOnly:!0})],D.prototype,"required",null),e([n()],D.prototype,"sortable",null),e([n()],D.prototype,"store",void 0),e([n()],D.prototype,"template",void 0),e([n()],D.prototype,"updateRowItemFunction",void 0),e([n()],D.prototype,"updateStoreItemFunction",void 0),D=e([i("esri.widgets.FeatureTable.FieldColumn")],D);const w=D;export{w as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{formatDate as o,convertDateFormatToIntlOptions as r}from"../../intl/date.js";import{convertNumberFormatToIntlOptions as a,formatNumber as l}from"../../intl/number.js";import s from"../../layers/support/CodedValueDomain.js";import{isEditableLayer as u}from"../../layers/support/editableLayers.js";import{isNumericField as d,isStringField as p}from"../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as c}from"../../layers/support/layerUtils.js";import{unsupportedDateFieldTypes as m,formatDateFieldValue as h}from"../FeatureForm/featureFormUtils.js";import f from"../FeatureForm/FieldInput.js";import g from"./Grid/EditorColumn.js";import y from"../support/DatePicker.js";import v from"../support/TimePicker.js";import{renderingSanitizer as b}from"../support/widgetUtils.js";const F={cancelEdit:"Escape"},_="esri-field-column",C={headerContent:`${_}__header-content`,headerLabel:`${_}__header-label`,input:`${_}__cell-input`,inputContainer:`${_}__cell__input-container`,dateInputContainer:`${_}__cell__date-input-container`,dateInputWrapper:`${_}__cell__date-input-wrapper`,button:`${_}__button`,saveIcon:"esri-icon-save",trashIcon:"esri-icon-trash",locked:"esri-icon-locked"},E=r("short-date-short-time"),I=r("short-date"),L={useGrouping:!0,maximumFractionDigits:20};let D=class extends g{constructor(e){super(e),this._inputField=null,this.cellValueFormatFunction=({rowData:e,value:t})=>{if(this.formatFunction){const{config:e,field:n}=this;return this.formatFunction({config:e,field:n,value:b.sanitize(t)})}if(null===t)return"&nbsp;";const{config:n,field:i}=this,r=e?.item?.feature,s=this._getDomainForFeature(r);if(s)return this._getComputedDomain(t,s);if("date"===i.type){const e=this._getDateFormatOptions(),n="feature"===this.layer?.type&&this.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null;return t?o(t,{...e,...n}):null}if(m.has(i.type)&&t){const e=h(i,t);return b.sanitize(e)}if(d(i)){const e=n?.format?a(n.format):L;return l(parseFloat(t),e)}return b.sanitize(t)},this.cellValueValidatorFunction=({oldValue:e,value:t})=>!(this._inputField&&!this._inputField.valid)&&((!this.required||null!=t&&""!==t)&&e!==t),this.config=null,this.editingEnabled=!1,this.expressionInfos=null,this.field=null,this.formatFunction=null,this.headerRenderFunction=e=>{const{root:t}=e,{editable:n,editingEnabled:i,headerMenuEnabled:o,sortable:r}=this;if(this.removeCellContent(t),t.classList.add(C.headerContent),i&&!n&&t.appendChild(this.createLockedElement()),r)this.headerSorterRenderFunction(e);else{const e=document.createElement("div");e.classList.add(C.headerLabel),e.textContent=this.label,t.appendChild(e)}o&&this.headerMenuRenderFunction(e)},this.inputRenderFunction=({root:e,column:t,rowData:n})=>{if(this.activeEditInfo?.updating)return;if(!this.editable)return;const i=this.getCellValue(t,n),o=this.createInputElement({root:e,column:t,rowData:n,value:i});if(this._set("activeEditInfo",{column:t,input:o,root:e,rowData:n,updating:!0,oldValue:i}),"date"===this.field.type)return void this._renderDateEditors(i,e,o);const r=this.createInputContainer();r.appendChild(o),this.removeCellContent(e),e.appendChild(r),o.focus(),o instanceof HTMLInputElement&&o.select(),this.grid?.notifyResize()},this.layer=null,this.parseInputValueFunction=({input:e})=>{const t=this._inputField;if(!t)return null;const n=e.value,{dataType:i,required:o}=t;return o||""!==n?"number"===i||"date"===i?parseFloat(n):"text"===i?n.trim():n:null},this.store=null,this.template=null,this.updateRowItemFunction=({rowData:e,column:t,value:n})=>{e&&(e.item.feature.attributes[t.path]=n)},this.updateStoreItemFunction=async({rowData:e,column:t,value:n})=>{if(!e||!this.store)return;const i=e.item.objectId,o=this.store.getObjectIdIndex(i)??e.index;await this.store.updateItem({index:o,name:t.path,value:n})}}get alias(){return this.field?.alias}get defaultValue(){return this.field?.defaultValue}get description(){return this.template?.description??this.config?.description??this.field?.description??null}get editable(){const{config:e,editingEnabled:t,field:n,layer:i,template:o}=this;if(null==n||null==i)return!1;const r=u(i),a=c(i),l=a?.operations.supportsUpdate;return!!(n.editable&&r&&l)&&(!m.has(n.type)&&(t?!(!1===o?.editable||!1===e?.editable):!(!o?.editable&&!e?.editable)))}get header(){return this.template?.label||this.config?.label||this.alias||this.path||null}get hidden(){const{config:e}=this;return!1===e?.visible||this._get("hidden")||!1}set hidden(e){this._set("hidden",e)}get loadingMessage(){return this.messages?.loading||"..."}get maxLength(){const{field:e,config:t,template:n}=this,i=e?.length,o=n?.input&&"maxLength"in n.input?n.input.maxLength:t?.maxLength;return null!=o&&!isNaN(o)&&o>=-1&&(-1===i||o<=i)?o:i}get minLength(){const{config:e,template:t,maxLength:n}=this,i=t?.input&&"minLength"in t.input?t.input.minLength:e?.minLength||null;return n&&i<=n?i:null}get name(){return this.field?.name}get nullable(){return this.field?.nullable??!1}get path(){return this.field?.name}get required(){const{config:e,field:t,template:n}=this,i=t?.nullable,o=e?.required,r=n?.required;return this.editable&&(!i||!0===o||!0===r)}get sortable(){return this.template?!1!==this.template?.sortable:!1!==this.config?.sortable}createInputElement({rowData:e,value:t}){const n=e?.item;if(!n||!n.feature)return null;this._inputField=this._setUpInputField(n.feature,t);const{field:i,maxLength:o,minLength:r,required:a}=this,{domain:l}=this._inputField;let s;"coded-value"===l?.type?(s=this._createSelectElement(t,l.codedValues.map((({code:e,name:t})=>({value:e,name:t}))),this._inputField),s.onchange=()=>{s.onblur=null,p()}):(s=document.createElement("input"),s.type=d(i)?"number":"text",o>-1&&(s.maxLength=o),r>0&&(s.minLength=r)),s.classList.add(C.input),s.value=t,s.required=a;let u=!1;s.onkeydown=e=>{u=e.key===F.cancelEdit},s.onblur=()=>{s.onblur=null,p()};const p=()=>{u?this.cancel():this.submit(),this._inputField=null};return s}createInputContainer(){const e=document.createElement("div");return e.classList.add(C.inputContainer),e}createLockedElement(){const e=document.createElement("div");return e.classList.add(C.locked),e}getCellValue({path:e},t){return t?.item?.feature?.attributes?.[e]??null}_renderDateEditors(e,n,i){const{config:o,messagesCommon:r,template:a}=this,l=e?new Date(e):new Date(Date.now()),s=new y({dateInputEnabled:!0,value:l}),u=new v({value:l});i.value=l.getTime().toString();let d=!e;const p=()=>{d=!0;const e=this._getCombinedDateTime(s.value,u.value);i.value=e.getTime().toString()},c=()=>{d?this.submit():this.cancel()},m=()=>{i.value=null,this.submit()};t((()=>[s.value,u.value]),(()=>p()));const h=document.createElement("div"),f=document.createElement("div");s.container=h,u.container=f;const g=document.createElement("button");g.classList.add(C.button,C.saveIcon),g.onclick=()=>c(),g.title=r?.save;const b=document.createElement("button");b.classList.add(C.button,C.trashIcon),b.onclick=()=>m(),b.title=r?.clear;const F=document.createElement("div");F.classList.add(C.dateInputWrapper),F.appendChild(h),(a&&a.input&&"datetime-picker"===a.input.type&&!1!==a.input.includeTime||o&&!1!==o.includeTime)&&F.appendChild(f);const _=document.createElement("div");_.classList.add(C.dateInputContainer),_.appendChild(F),_.appendChild(g),_.appendChild(b),s.when((()=>{const e=s._inputOrButtonNode;e&&(e.onblur=e=>{const t=e.relatedTarget;t&&t.className.includes("esri-date-picker")||s.close(!1)}),this.grid?.notifyResize()})),u.when((()=>this.grid?.notifyResize())),this.removeCellContent(n),n.appendChild(_),this.grid?.notifyResize()}_createSelectElement(e,t,n){let i=!1;const o=t.map((t=>{t.value===e&&(i=!0);const n=document.createElement("option");return n.text=t.name,n.value=t.value,n}));if(null!=e&&""!==e&&!i){const t=document.createElement("option");t.text=e,t.value=e,o.unshift(t)}if(!n.required&&null==n.value){const e=document.createElement("option");e.value="",o.unshift(e)}const r=document.createElement("select");return o.forEach((e=>r.add(e))),r.value=e,r}_setUpInputField(e,t){const{field:n,layer:i}=this,o=new f({feature:e,initialFeature:e.clone(),field:n,layer:i});return o.set("value",t),o}_isDomainCompatible(e){const{field:t}=this;if(e&&"coded-value"===e.type){const n=typeof e.codedValues[0].code;if("string"===n&&p(t)||"number"===n&&d(t))return!0}return!(!e||"range"!==e.type||!d(t))}_getDomainForFeature(e){const{config:t,layer:n,name:i,template:o}=this;if(!n)return null;if("wfs"===n.type||"geojson"===n.type||"csv"===n.type)return null;if(o?.domain&&this._isDomainCompatible(o.domain))return o.domain;const{typeIdField:r}=n,a=r===i,l=this.field.domain;if(a&&!l)return new s({name:"__internal-type-based-coded-value-domain__",codedValues:n.types?.map((({id:e,name:t})=>({code:e,name:t})))});const u=r&&null!=i&&n.getFieldDomain(i,{feature:e})||l,d=t?.domain;return this._isDomainCompatible(d)?d:u}_getComputedDomain(e,t){if(!t)return null;if("range"===t.type)return e;if("coded-value"===t.type){const n=t.codedValues.filter((t=>t.hasOwnProperty("code")&&t.code===e));return n&&n.length?n[0].name:e}return null}_getCombinedDateTime(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())}_getDateFormatOptions(){const{config:e,template:t}=this,n=t?.format?.dateFormat||e?.format?.dateFormat;return n?r(n):t&&t.input&&"includeTime"in t.input==!1||!1===e?.includeTime?I:E}};e([n({readOnly:!0})],D.prototype,"alias",null),e([n()],D.prototype,"cellValueFormatFunction",void 0),e([n()],D.prototype,"cellValueValidatorFunction",void 0),e([n()],D.prototype,"config",void 0),e([n({readOnly:!0})],D.prototype,"defaultValue",null),e([n({readOnly:!0})],D.prototype,"description",null),e([n({readOnly:!0})],D.prototype,"editable",null),e([n()],D.prototype,"editingEnabled",void 0),e([n()],D.prototype,"expressionInfos",void 0),e([n()],D.prototype,"field",void 0),e([n()],D.prototype,"formatFunction",void 0),e([n({readOnly:!0})],D.prototype,"header",null),e([n()],D.prototype,"hidden",null),e([n()],D.prototype,"headerRenderFunction",void 0),e([n()],D.prototype,"inputRenderFunction",void 0),e([n()],D.prototype,"layer",void 0),e([n({readOnly:!0})],D.prototype,"loadingMessage",null),e([n()],D.prototype,"maxLength",null),e([n()],D.prototype,"minLength",null),e([n({readOnly:!0})],D.prototype,"name",null),e([n({readOnly:!0})],D.prototype,"nullable",null),e([n()],D.prototype,"parseInputValueFunction",void 0),e([n({readOnly:!0})],D.prototype,"path",null),e([n({readOnly:!0})],D.prototype,"required",null),e([n()],D.prototype,"sortable",null),e([n()],D.prototype,"store",void 0),e([n()],D.prototype,"template",void 0),e([n()],D.prototype,"updateRowItemFunction",void 0),e([n()],D.prototype,"updateStoreItemFunction",void 0),D=e([i("esri.widgets.FeatureTable.FieldColumn")],D);const w=D;export{w as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Evented.js";import{HandleOwnerMixin as r}from"../../core/HandleOwner.js";import s from"../../core/ObjectPool.js";import{when as o}from"../../core/reactiveUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as i}from"../../layers/support/layerUtils.js";import n from"./TemplateItem.js";import p from"./TemplateItemGroup.js";var u;const m=({layer:e})=>({key:e,label:e.title??""}),y=({layer:e})=>({key:e.geometryType,label:e.geometryType??""});let c=u=class extends(r(t.EventedAccessor)){constructor(e){super(e),this._itemPool=new s(n),this._groupPool=new s(p),this.filterFunction=null,this.selectedItem=null}initialize(){this._get("groupBy")||(this.groupBy="layer")}set groupBy(e){if(this._set("groupBy",e),"function"!=typeof e)switch(e){case"layer":this._groupByFunction=m;break;case"geometry":this._groupByFunction=y;break;default:this._groupByFunction=null}else this._groupByFunction=t=>this._ensureGroupByObject(e(t))}set layers(e){const t="layers";if(this.handles.remove(t),e){const r=()=>this.notifyChange("state");this.handles.add(e.map((e=>o((()=>e.loadStatus),r))),t)}this._set("layers",e)}get layers(){return this._get("layers")}get state(){const{layers:e}=this;return e&&0!==e.length?e.some((e=>"loading"===e.loadStatus||"not-loaded"===e.loadStatus))?"loading":"ready":"disabled"}get _featureTemplatesByLayer(){if(!this.layers)return new Map;const e=[];for(const t of this.layers)if("subtype-group"===t.type)for(const r of t.sublayers){const t=h(r);e.push([r,t])}else e.push([t,h(t)]);return new Map(e)}get numberOfFeatureTemplates(){return Array.from(this._featureTemplatesByLayer.values()).reduce(((e,t)=>e+t.length),0)}get items(){if(0===this.numberOfFeatureTemplates)return this._releasePreviousItems(),[];const e=this._featureTemplatesByLayer,t=[],r=null!=this.filterFunction?this.filterFunction:u._nullFilterFunction;for(const[l,a]of e)if(l.loaded||"subtype-sublayer"===l.type&&l.parent?.loaded){const e=i(l)?.operations;if(e?.supportsEditing&&e?.supportsAdd)for(const s of a)t.push({layer:l,template:s,matchesFilter:r({label:s.name})})}if(null==this._groupByFunction){const e=t.filter((({matchesFilter:e})=>e)).map((({template:e,layer:t})=>this._createItem(e,t)));return this._releasePreviousItems(),e}const s=new Map;for(const l of t){const{template:e,layer:t}=l,r=this._groupByFunction({template:e,layer:t}),{key:o,label:a}=null!=r.key?r:u.nullGroupBy;s.has(o)||s.set(o,{label:a,templateItemInfos:[]}),s.get(o)?.templateItemInfos.push(l)}const o=[];for(const l of s.values()){const{label:e,templateItemInfos:t}=l,s=t.filter((({matchesFilter:e})=>e)),a=r({label:e})?t:t.length>0?s:[];if(a.length>0){const t=a.map((({template:e,layer:t})=>this._createItem(e,t)));o.push(this._createGroup(e,t))}}return 1===o.length&&o[0].label===u.nullGroupBy.label?(this._releasePreviousItems(),o[0].items):(this._releasePreviousItems(),o)}refresh(){this.notifyChange("items")}select(e,{emit:t=!0}={}){const r=this.selectedItem,s=e?.clone()||null;this._set("selectedItem",s),t&&this.emit("select",{item:s,oldItem:r,template:s?.template??null})}_createItem(e,t){const r=this._itemPool.acquire();return r.set({template:e,layer:t}),r}_createGroup(e,t){const r=this._groupPool.acquire();return r.set("label",e),r.items=t,r}_releasePreviousItems(){this._destroyItems(this._get("items"))}_destroyItems(e){if(!e)return;e[0]instanceof n?e.forEach((e=>this._destroyItem(e))):e.forEach((e=>this._destroyGroup(e)))}_destroyGroup(e){e.items.forEach((e=>this._destroyItem(e))),e.items.length=0,this._groupPool.release(e)}_destroyItem(e){e.layer=null,e.template=null,this._itemPool.release(e)}_ensureGroupByObject(e){return"string"==typeof e?{key:e,label:e}:e}};c.nullGroupBy={key:Symbol(),label:"Other​"},c._nullFilterFunction=e=>!0,e([l()],c.prototype,"_groupByFunction",void 0),e([l()],c.prototype,"filterFunction",void 0),e([l()],c.prototype,"groupBy",null),e([l()],c.prototype,"layers",null),e([l()],c.prototype,"state",null),e([l({readOnly:!0})],c.prototype,"_featureTemplatesByLayer",null),e([l({readOnly:!0})],c.prototype,"numberOfFeatureTemplates",null),e([l({readOnly:!0})],c.prototype,"items",null),e([l({readOnly:!0})],c.prototype,"selectedItem",void 0),c=u=e([a("esri.widgets.FeatureTemplates.FeatureTemplatesViewModel")],c);const h=e=>[..."templates"in e&&Array.isArray(e.templates)?e.templates:[],..."types"in e&&Array.isArray(e.types)?e.types.flatMap((e=>e.templates)):[]],f=c;export{f as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Evented.js";import{HandleOwnerMixin as r}from"../../core/HandleOwner.js";import s from"../../core/ObjectPool.js";import{when as o}from"../../core/reactiveUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{isTable as i,getEffectiveLayerCapabilities as n}from"../../layers/support/layerUtils.js";import p from"./TemplateItem.js";import u from"./TemplateItemGroup.js";var m;const y=({layer:e})=>({key:e,label:e.title??""}),c=({layer:e})=>({key:e.geometryType,label:e.geometryType??""});let h=m=class extends(r(t.EventedAccessor)){constructor(e){super(e),this._itemPool=new s(p),this._groupPool=new s(u),this.filterFunction=null,this.selectedItem=null}initialize(){this._get("groupBy")||(this.groupBy="layer")}set groupBy(e){if(this._set("groupBy",e),"function"!=typeof e)switch(e){case"layer":this._groupByFunction=y;break;case"geometry":this._groupByFunction=c;break;default:this._groupByFunction=null}else this._groupByFunction=t=>this._ensureGroupByObject(e(t))}set layers(e){const t="layers";if(this.handles.remove(t),e){const r=()=>this.notifyChange("state");this.handles.add(e.map((e=>o((()=>e.loadStatus),r))),t)}this._set("layers",e)}get layers(){return this._get("layers")}get state(){const{layers:e}=this;return e&&0!==e.length?e.some((e=>"loading"===e.loadStatus||"not-loaded"===e.loadStatus))?"loading":"ready":"disabled"}get _featureTemplatesByLayer(){if(!this.layers)return new Map;const e=[];for(const t of this.layers)if("subtype-group"===t.type)for(const r of t.sublayers){const t=f(r);e.push([r,t])}else i(t)||e.push([t,f(t)]);return new Map(e)}get numberOfFeatureTemplates(){return Array.from(this._featureTemplatesByLayer.values()).reduce(((e,t)=>e+t.length),0)}get items(){if(0===this.numberOfFeatureTemplates)return this._releasePreviousItems(),[];const e=this._featureTemplatesByLayer,t=[],r=null!=this.filterFunction?this.filterFunction:m._nullFilterFunction;for(const[l,a]of e)if(l.loaded||"subtype-sublayer"===l.type&&l.parent?.loaded){const e=n(l)?.operations;if(e?.supportsEditing&&e?.supportsAdd)for(const s of a)t.push({layer:l,template:s,matchesFilter:r({label:s.name})})}if(null==this._groupByFunction){const e=t.filter((({matchesFilter:e})=>e)).map((({template:e,layer:t})=>this._createItem(e,t)));return this._releasePreviousItems(),e}const s=new Map;for(const l of t){const{template:e,layer:t}=l,r=this._groupByFunction({template:e,layer:t}),{key:o,label:a}=null!=r.key?r:m.nullGroupBy;s.has(o)||s.set(o,{label:a,templateItemInfos:[]}),s.get(o)?.templateItemInfos.push(l)}const o=[];for(const l of s.values()){const{label:e,templateItemInfos:t}=l,s=t.filter((({matchesFilter:e})=>e)),a=r({label:e})?t:t.length>0?s:[];if(a.length>0){const t=a.map((({template:e,layer:t})=>this._createItem(e,t)));o.push(this._createGroup(e,t))}}return 1===o.length&&o[0].label===m.nullGroupBy.label?(this._releasePreviousItems(),o[0].items):(this._releasePreviousItems(),o)}refresh(){this.notifyChange("items")}select(e,{emit:t=!0}={}){const r=this.selectedItem,s=e?.clone()||null;this._set("selectedItem",s),t&&this.emit("select",{item:s,oldItem:r,template:s?.template??null})}_createItem(e,t){const r=this._itemPool.acquire();return r.set({template:e,layer:t}),r}_createGroup(e,t){const r=this._groupPool.acquire();return r.set("label",e),r.items=t,r}_releasePreviousItems(){this._destroyItems(this._get("items"))}_destroyItems(e){if(!e)return;e[0]instanceof p?e.forEach((e=>this._destroyItem(e))):e.forEach((e=>this._destroyGroup(e)))}_destroyGroup(e){e.items.forEach((e=>this._destroyItem(e))),e.items.length=0,this._groupPool.release(e)}_destroyItem(e){e.layer=null,e.template=null,this._itemPool.release(e)}_ensureGroupByObject(e){return"string"==typeof e?{key:e,label:e}:e}};h.nullGroupBy={key:Symbol(),label:"Other​"},h._nullFilterFunction=e=>!0,e([l()],h.prototype,"_groupByFunction",void 0),e([l()],h.prototype,"filterFunction",void 0),e([l()],h.prototype,"groupBy",null),e([l()],h.prototype,"layers",null),e([l()],h.prototype,"state",null),e([l({readOnly:!0})],h.prototype,"_featureTemplatesByLayer",null),e([l({readOnly:!0})],h.prototype,"numberOfFeatureTemplates",null),e([l({readOnly:!0})],h.prototype,"items",null),e([l({readOnly:!0})],h.prototype,"selectedItem",void 0),h=m=e([a("esri.widgets.FeatureTemplates.FeatureTemplatesViewModel")],h);const f=e=>[..."templates"in e&&Array.isArray(e.templates)?e.templates:[],..."types"in e&&Array.isArray(e.types)?e.types.flatMap((e=>e.templates)):[]],d=h;export{d as default};