@arcgis/core 5.1.0-next.95 → 5.1.0-next.97

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 (138) hide show
  1. package/Graphic.d.ts +16 -1
  2. package/Graphic.js +1 -1
  3. package/applications/MapViewer/templateUtils.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/0175098da590a7109539.js +1 -0
  6. package/assets/esri/core/workers/chunks/0e6feed31340cf3c1966.js +1 -0
  7. package/assets/esri/core/workers/chunks/26f28406056ddc0e159c.js +1 -0
  8. package/assets/esri/core/workers/chunks/27d6ad4ca5ab8c9d62cd.js +1 -0
  9. package/assets/esri/core/workers/chunks/{23241e6093e245f9c774.js → 2b00229c238aae70b948.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{6b4c99c7648f37feec00.js → 308e1b0aea941958de44.js} +1 -1
  11. package/assets/esri/core/workers/chunks/34c11e7c8762fe0c19fb.js +1 -0
  12. package/assets/esri/core/workers/chunks/34e026549ba2822b8ebd.js +1 -0
  13. package/assets/esri/core/workers/chunks/4020f95d8131493f799e.js +1 -0
  14. package/assets/esri/core/workers/chunks/40bc7c65b708fcc80fab.js +1 -0
  15. package/assets/esri/core/workers/chunks/{8de61993e114f453579b.js → 40e887e87ae24ace27a5.js} +1 -1
  16. package/assets/esri/core/workers/chunks/4255ad7601c7a7621b71.js +1 -0
  17. package/assets/esri/core/workers/chunks/{5853925d2f7fb550bd2e.js → 44b5e4640fe547285e0c.js} +1 -1
  18. package/assets/esri/core/workers/chunks/58c15c42e6a618386a2f.js +1 -0
  19. package/assets/esri/core/workers/chunks/6d59a9cf533ebc590f70.js +1 -0
  20. package/assets/esri/core/workers/chunks/{0f527961805cd45c14e2.js → 708bd77e6d723e3f0aa8.js} +1 -1
  21. package/assets/esri/core/workers/chunks/7485d59d60d61737d662.js +1 -0
  22. package/assets/esri/core/workers/chunks/7dc9ff66e1eceadbae24.js +1 -0
  23. package/assets/esri/core/workers/chunks/9954928d6430e2bfdb1a.js +1 -0
  24. package/assets/esri/core/workers/chunks/9a29b7f9e6281ee40c37.js +1 -0
  25. package/assets/esri/core/workers/chunks/9f4a9b193485f88d4461.js +1 -0
  26. package/assets/esri/core/workers/chunks/a001e7e8a39f27284d87.js +1 -0
  27. package/assets/esri/core/workers/chunks/a93a058678c8c8996d54.js +1 -0
  28. package/assets/esri/core/workers/chunks/acb8cff06142f828fb78.js +1 -0
  29. package/assets/esri/core/workers/chunks/{bf73232057ebc1ecc0ad.js → b06cc59068d32baaaa87.js} +1 -1
  30. package/assets/esri/core/workers/chunks/b63cbf6c2c9ec1b02b9a.js +1 -0
  31. package/assets/esri/core/workers/chunks/b891d95b7858665cd6c1.js +1 -0
  32. package/assets/esri/core/workers/chunks/bfb417d72d0c90e116fe.js +1 -0
  33. package/assets/esri/core/workers/chunks/c0c693c2e0043ecba4a5.js +1 -0
  34. package/assets/esri/core/workers/chunks/{fa869bfe4366f7f49cca.js → e5f8c73349407c25956b.js} +1 -1
  35. package/assets/esri/core/workers/chunks/e8a885b576da3ec145d3.js +1 -0
  36. package/assets/esri/core/workers/chunks/{bd721bbc7afc75d3bddb.js → eda51e512eff551ad858.js} +1 -1
  37. package/assets/esri/core/workers/chunks/f27397379c6c88bc6ef4.js +1 -0
  38. package/assets/esri/core/workers/chunks/f91a2c69a93295cf4de6.js +1 -0
  39. package/assets/esri/core/workers/chunks/fec3fffcf854a6226df4.js +1 -0
  40. package/chunks/GaussianSplat.glsl.js +9 -9
  41. package/chunks/NativeLine.glsl.js +4 -4
  42. package/config.js +1 -1
  43. package/kernel.js +1 -1
  44. package/layers/SceneLayer.d.ts +59 -32
  45. package/layers/graphics/data/QueryEngineCapabilities.js +1 -1
  46. package/layers/graphics/sources/OGCFeatureSource.js +1 -1
  47. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  48. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  49. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  50. package/layers/mixins/ArcGISImageService.js +1 -1
  51. package/layers/raster/formats/Lerc.js +1 -1
  52. package/layers/raster/formats/RasterCodec.js +1 -1
  53. package/layers/scene/ModelFileInfo.d.ts +6 -2
  54. package/layers/scene/ModelInfo.d.ts +16 -7
  55. package/layers/scene/types.d.ts +2 -0
  56. package/layers/support/ExportImageServiceParameters.js +1 -1
  57. package/layers/support/capabilities.js +1 -1
  58. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  59. package/layers/types.d.ts +25 -2
  60. package/package.json +1 -1
  61. package/rest/knowledgeGraph/CreateReplicaResponse.d.ts +5 -4
  62. package/rest/knowledgeGraph/wasmInterface/wasmToReplicaFactories.js +1 -1
  63. package/rest/query/operations/queryUtils.js +1 -1
  64. package/rest/support/OutDistance.js +1 -1
  65. package/rest/support/Query.d.ts +39 -1
  66. package/rest/support/Query.js +1 -1
  67. package/support/revision.js +1 -1
  68. package/tables/AttributeTableTemplate.d.ts +1 -1
  69. package/tables/elements/AttributeTableGroupElement.d.ts +1 -1
  70. package/tables/support/tablesUtils.d.ts +2 -2
  71. package/tables/support/templateUtils.d.ts +136 -0
  72. package/tables/support/templateUtils.js +2 -0
  73. package/tables/support/types.d.ts +90 -0
  74. package/views/2d/engine/webgl/definitions.js +1 -1
  75. package/views/2d/engine/webgl/shaderGraph/techniques/animated/attributes.js +1 -1
  76. package/views/2d/engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js +1 -1
  77. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  78. package/views/2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js +1 -1
  79. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  80. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js +1 -1
  81. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartShader.js +1 -1
  82. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  83. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  84. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  85. package/views/2d/layers/BaseLayerView2D.d.ts +2 -2
  86. package/views/2d/layers/BaseLayerViewGL2D.d.ts +2 -2
  87. package/views/3d/support/QualityProfile.js +1 -1
  88. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  89. package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
  90. package/views/3d/support/gaussianSplatting/GaussianTile.js +1 -1
  91. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +6 -19
  92. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  93. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  94. package/views/3d/webgl-engine/shaders/NativeLine.glsl.js +1 -1
  95. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.d.ts +40 -1
  96. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  97. package/widgets/BatchAttributeForm/ReactiveGraphic.js +1 -1
  98. package/widgets/BatchAttributeForm/expressions/types.d.ts +1 -0
  99. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.d.ts +52 -1
  100. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  101. package/widgets/BatchAttributeForm/inputs/BatchFormInputs.d.ts +3 -0
  102. package/widgets/BatchAttributeForm/inputs/BatchFormInputs.js +1 -1
  103. package/widgets/BatchAttributeForm/inputs/EditableInput.d.ts +2 -0
  104. package/widgets/BatchAttributeForm/inputs/EditableInput.js +1 -1
  105. package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
  106. package/widgets/BatchAttributeForm/types.d.ts +79 -0
  107. package/widgets/Editor/Edits.js +1 -1
  108. package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
  109. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  110. package/assets/esri/core/workers/chunks/0ab1384282afc8731857.js +0 -1
  111. package/assets/esri/core/workers/chunks/130abc6a353e4d79a1b1.js +0 -1
  112. package/assets/esri/core/workers/chunks/1a68a249540fda9083a9.js +0 -1
  113. package/assets/esri/core/workers/chunks/1ae016e4f5e39c34a941.js +0 -1
  114. package/assets/esri/core/workers/chunks/2f6ba01ea8b8f193bea5.js +0 -1
  115. package/assets/esri/core/workers/chunks/31837f2f8859e2cf2efd.js +0 -1
  116. package/assets/esri/core/workers/chunks/41e811138c96d85fd3e8.js +0 -1
  117. package/assets/esri/core/workers/chunks/43b5cfb34b11c4124b51.js +0 -1
  118. package/assets/esri/core/workers/chunks/44b30dfce12824ee1f33.js +0 -1
  119. package/assets/esri/core/workers/chunks/4644e1b00fd4e628219d.js +0 -1
  120. package/assets/esri/core/workers/chunks/5648379d1ed4ca02eedd.js +0 -1
  121. package/assets/esri/core/workers/chunks/6666cd3bf1a3d175dc8c.js +0 -1
  122. package/assets/esri/core/workers/chunks/7536f0683e488159d8bd.js +0 -1
  123. package/assets/esri/core/workers/chunks/8bfe4841c83eb3abfbe8.js +0 -1
  124. package/assets/esri/core/workers/chunks/a12fd6a445f42326642f.js +0 -1
  125. package/assets/esri/core/workers/chunks/a8e2fbbfbdf1c3203d5e.js +0 -1
  126. package/assets/esri/core/workers/chunks/a94674826e5893c9d197.js +0 -1
  127. package/assets/esri/core/workers/chunks/b2504657d3ef8769005e.js +0 -1
  128. package/assets/esri/core/workers/chunks/b90db0829da3f96e4a19.js +0 -1
  129. package/assets/esri/core/workers/chunks/bd9dae2d5ec199f8e9ba.js +0 -1
  130. package/assets/esri/core/workers/chunks/be19d4a6fb9b1c923127.js +0 -1
  131. package/assets/esri/core/workers/chunks/c2589e5e0e0f81a378c2.js +0 -1
  132. package/assets/esri/core/workers/chunks/c33f1f722499a5c6fc11.js +0 -1
  133. package/assets/esri/core/workers/chunks/e03713dee3205c96d53f.js +0 -1
  134. package/assets/esri/core/workers/chunks/ead6e4d0a515c0913bee.js +0 -1
  135. package/assets/esri/core/workers/chunks/f95e3333a65a0c09fd1e.js +0 -1
  136. package/assets/esri/core/workers/chunks/ffb8fa77297578afef7c.js +0 -1
  137. package/tables/types.d.ts +0 -18
  138. package/widgets/FeatureTable/support/templateUtils.js +0 -2
@@ -1,31 +1,18 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{create as a}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ForwardLinearDepthToReadShadowMap as o}from"../ForwardLinearDepthToReadShadowMap.glsl.js";import{calculateUVZShadowPass as e,calculateUVZShadowDraw as t,ReadShadowMapOrigin as d}from"./calculateUVZShadow.glsl.js";import{ShadowmapFiltering as r}from"./ShadowmapFiltering.glsl.js";import{BooleanBindUniform as i}from"../../shaderModules/BooleanBindUniform.js";import{FloatBindUniform as n}from"../../shaderModules/FloatBindUniform.js";import{If as l,glsl as h}from"../../shaderModules/glsl.js";import{Texture2DBindUniform as s}from"../../shaderModules/Texture2DBindUniform.js";import{Texture2DShadowBindUniform as w}from"../../shaderModules/Texture2DShadowBindUniform.js";import{NoParameters as c}from"../../../../../webgl/NoParameters.js";class u extends d{}class f extends c{constructor(){super(...arguments),this.origin=a()}}function g(a,o){o.receiveShadows&&a.fragment.include(e),S(a,o)}function p(a,o){o.receiveShadows&&a.fragment.include(t),S(a,o)}function m(a,o){o.receiveShadows&&a.vertex.include(e),v(a,o)}function S(a,e){a.fragment.uniforms.add(new n("lightingGlobalFactor",a=>a.lighting.globalFactor));const{hasShadowHighlights:t,receiveShadows:d,spherical:r}=e;a.include(o,e),d&&M(a.fragment,t),a.fragment.code.add(h`
2
+ import{create as a}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ForwardLinearDepthToReadShadowMap as o}from"../ForwardLinearDepthToReadShadowMap.glsl.js";import{calculateUVZShadowPass as e,calculateUVZShadowDraw as t,ReadShadowMapOrigin as r}from"./calculateUVZShadow.glsl.js";import{ShadowmapFiltering as d}from"./ShadowmapFiltering.glsl.js";import{FloatBindUniform as i}from"../../shaderModules/FloatBindUniform.js";import{If as n,glsl as s}from"../../shaderModules/glsl.js";import{Texture2DBindUniform as l}from"../../shaderModules/Texture2DBindUniform.js";import{Texture2DShadowBindUniform as h}from"../../shaderModules/Texture2DShadowBindUniform.js";import{NoParameters as c}from"../../../../../webgl/NoParameters.js";class u extends r{}class w extends c{constructor(){super(...arguments),this.origin=a()}}function f(a,o){o.receiveShadows&&a.fragment.include(e),g(a,o)}function m(a,o){o.receiveShadows&&a.fragment.include(t),g(a,o)}function g(a,e){a.fragment.uniforms.add(new i("lightingGlobalFactor",a=>a.lighting.globalFactor));const{hasShadowHighlights:t,receiveShadows:r,spherical:d}=e;a.include(o,e),r&&p(a.fragment,t),a.fragment.code.add(s`
3
3
  float readShadow(float additionalAmbientScale, vec3 vpos) {
4
- return ${d?"max(lightingGlobalFactor * (1.0 - additionalAmbientScale), readShadowMap(vpos, linearDepth))":l(r,"lightingGlobalFactor * (1.0 - additionalAmbientScale)","0.0")};
4
+ return ${r?"max(lightingGlobalFactor * (1.0 - additionalAmbientScale), readShadowMap(vpos, linearDepth))":n(d,"lightingGlobalFactor * (1.0 - additionalAmbientScale)","0.0")};
5
5
  }
6
- `)}function v(a,o){a.vertex.uniforms.add(new n("lightingGlobalFactor",a=>a.lighting.globalFactor));const{receiveShadows:e,spherical:t}=o;e&&x(a.vertex),a.vertex.code.add(h`
7
- float readShadowVertex(float additionalAmbientScale, vec3 vpos, float linearDepth) {
8
- return ${e?"max(lightingGlobalFactor * (1.0 - additionalAmbientScale), readShadowMap(vpos, linearDepth))":l(t,"lightingGlobalFactor * (1.0 - additionalAmbientScale)","0.0")};
9
- }
10
- `)}function M(a,o){F(a,o),b(a)}function x(a){z(a),b(a)}function b(a){a.code.add(h`float readShadowMap(const in vec3 _worldPos, float _linearDepth) {
6
+ `)}function p(a,o){v(a,o),S(a)}function S(a){a.code.add(s`float readShadowMap(const in vec3 _worldPos, float _linearDepth) {
11
7
  vec3 uvzShadow = calculateUVZShadow(_worldPos, _linearDepth, textureSize(shadowMap, 0));
12
8
  return readShadowMaps(uvzShadow);
13
- }`)}function F(a,o){a.include(r),a.uniforms.add(j()),o&&a.uniforms.add(new s("shadowHighlight",({shadowHighlight:a})=>a?.getTexture())),a.code.add(h`
9
+ }`)}function v(a,o){a.include(d),a.uniforms.add(M()),o&&a.uniforms.add(new l("shadowHighlight",({shadowHighlight:a})=>a?.getTexture())),a.code.add(s`
14
10
  float readShadowMaps(const in vec3 uvzShadow) {
15
11
  if (uvzShadow.z < 0.0) {
16
12
  return 0.0;
17
13
  }
18
14
 
19
15
  float shadow1 = readShadowMapUVZ(uvzShadow, shadowMap);
20
- ${l(o,"float shadow2 = texelFetch(shadowHighlight, ivec2(gl_FragCoord.xy), 0).r;\n return shadow1 > shadow2 ? shadow1 : shadow2;","return shadow1;")}
16
+ ${n(o,"float shadow2 = texelFetch(shadowHighlight, ivec2(gl_FragCoord.xy), 0).r;\n return shadow1 > shadow2 ? shadow1 : shadow2;","return shadow1;")}
21
17
  }
22
- `)}function z(a){a.include(r),a.uniforms.add(new i("singleShadowMap",({shadowMap:a})=>!!a.getOutput(5)),j(),new w("shadowMapHighlight",({shadowMap:a})=>a.getOutput(5)??a.getOutput(6))).code.add(h`float readShadowMaps(const in vec3 uvzShadow) {
23
- if (uvzShadow.z < 0.0) {
24
- return 0.0;
25
- }
26
- float shadow1 = readShadowMapUVZ(uvzShadow, shadowMap);
27
- if (singleShadowMap)
28
- return shadow1;
29
- float shadow2 = readShadowMapUVZ(uvzShadow, shadowMapHighlight);
30
- return shadow1 > shadow2 ? shadow1 : shadow2;
31
- }`)}function j(){return new w("shadowMap",({shadowMap:a})=>a.getOutput(5)??a.getOutput(7))}export{p as ReadShadowMapDrawFragment,u as ReadShadowMapDrawParameters,g as ReadShadowMapPassFragment,f as ReadShadowMapPassParameters,m as ReadShadowMapPassVertex,F as readShadowMapsFragment};
18
+ `)}function M(){return new h("shadowMap",({shadowMap:a})=>a.getOutput(5)??a.getOutput(7))}export{m as ReadShadowMapDrawFragment,u as ReadShadowMapDrawParameters,f as ReadShadowMapPassFragment,w as ReadShadowMapPassParameters,v as readShadowMapsFragment};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as i,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as r,set as o,scale as n,floor as h,subtract as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as m,set as u,positiveInfinity as c,equals as d}from"../../../../geometry/support/aaBoundingBox.js";import{InternalRenderCategory as _}from"../../webgl.js";import g from"../../webgl/RenderNode.js";import{G as f}from"../../../../chunks/GaussianSplat.glsl.js";import{G as P}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as C}from"../shaders/GaussianSplatCompositionTechnique.js";import{GaussianSplatCompositionTechniqueConfiguration as b}from"../shaders/GaussianSplatCompositionTechniqueConfiguration.js";import{G as S}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as x}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatTechnique as v}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as q}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{ColorAttachment1 as w,DepthStencilAttachment as E,PrimitiveType as y}from"../../../webgl/enums.js";var D;let R=class extends g{static{D=this}constructor(e){super(e),this.produces=_.GAUSSIAN_SPLAT,this.consumes={required:[_.GAUSSIAN_SPLAT]},this._slicePlaneEnabled=!1,this.layerView=null,this._passParameters=new f,this._compositionPassParameters=new P,this._depthCompositionPassParameters=new S,this._compositionConfiguration=new b,this._clipBox=m(),this._previousCameraDirection=p(),this._previousSortRequestCameraDirection=p(),this._sortRequestDirectionEpsilon=.01,this._directionChangeEpsilon=.001,this._configuration=new q(e.view.state.isGlobal),u(this._clipBox,c)}async initialize(){this.addHandles([t(()=>this.view.state.camera,()=>this._onCameraChange()),t(()=>2===this.view.state.mode,()=>this.requestRender(1))])}render(e){const t=e.find(({name:e})=>e===this.produces);if(this._updateConfigurations(),this._handleFading(),!this._data.visibleGaussians||!this._data.orderTexture.texture||!this._data.textureAtlas.texture)return t;const i=t.getAttachment(w);this._compositionConfiguration.hasEmission=null!=i;const s=this.techniques.getCompiled(v,this._configuration),a=this.techniques.getCompiled(C,this._compositionConfiguration),r=this.techniques.getCompiled(x);if(!s||!r||!a)return this.requestRender(1),t;const{fullWidth:o,fullHeight:n}=this.bindParameters.camera;this._prepareParameters(n,o);const h=this.renderingContext,l=this.fboCache,p=l.acquire(o,n,"gaussian color output"),m=t.getAttachment(E);p.attachDepth(m),this._renderGaussianColorAndDepth(p,s);const u=l.acquire(o,n,this.produces);return this._depthCompositionPassParameters.splatDepth=p.getTexture(w),u.attachDepth(t.getAttachment(E)),h.bindFramebuffer(u.fbo),h.bindTechnique(r,this.bindParameters,this._depthCompositionPassParameters),h.screen.draw(),this._compositionPassParameters.color=t.getTexture(),this._compositionPassParameters.splatColor=p.getTexture(),i?(u.acquireColor(w,8,"emissive"),this._compositionPassParameters.emission=t.getTexture(w)):this._compositionPassParameters.emission=null,h.bindFramebuffer(u.fbo),h.bindTechnique(a,this.bindParameters,this._compositionPassParameters),h.screen.draw(),p.release(),u}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this.requestRender(1))}set clippingBox(e){const t=e||c;this._hasSameClipBox(t)||(u(this._clipBox,t),this._data.requestSort(),this.requestRender(1))}get clippingBox(){return this._clippingEnabled?this._clipBox:null}get _clippingEnabled(){return!d(this._clipBox,c,(e,t)=>e===t)}get _isIdle(){return 2===this.view.state.mode}get _fragmentShadowsEnabled(){return this._isIdle}get _data(){return this.layerView.data}get _fadeHelper(){return this.layerView.fadeHelper}_updateConfigurations(){const{idleMinimumOpacity:e,nonIdleMinimumOpacity:t}=this.view.qualitySettings.gaussianSplat;this._configuration.alphaCutoff=this._isIdle?e:t,this._configuration.fadingEnabled=this._fadeHelper.fadingEnabled,this._configuration.receiveShadows=this.bindParameters.shadowMap.ready,this._configuration.fragmentShadows=this._configuration.receiveShadows&&this._fragmentShadowsEnabled,this._configuration.hasShadowHighlights=this._configuration.fragmentShadows&&this.bindParameters.hasShadowHighlights,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.hasSlicePlane=this._slicePlaneEnabled&&null!=this.bindParameters.slicePlane}destroy(){super.destroy()}_onCameraChange(){const e=this.view.state.camera.ray.direction;if(!this._directionChanged(e))return;if(r(this._previousCameraDirection,e),!this._shouldRequestSort(e))return;this._data.requestSort()&&r(this._previousSortRequestCameraDirection,e)}_directionChanged(e){return Math.abs(e[0]-this._previousCameraDirection[0])>this._directionChangeEpsilon||Math.abs(e[1]-this._previousCameraDirection[1])>this._directionChangeEpsilon||Math.abs(e[2]-this._previousCameraDirection[2])>this._directionChangeEpsilon}_shouldRequestSort(e){return Math.abs(e[0]-this._previousSortRequestCameraDirection[0])>this._sortRequestDirectionEpsilon||Math.abs(e[1]-this._previousSortRequestCameraDirection[1])>this._sortRequestDirectionEpsilon||Math.abs(e[2]-this._previousSortRequestCameraDirection[2])>this._sortRequestDirectionEpsilon}_prepareParameters(e,t){this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture;const i=Math.tan(.5*this.camera.fovY),s=i/e*t;a(this._passParameters.tanFov,s,i),this._passParameters.focalLength=e/(2*i);const o=this.view.qualitySettings.gaussianSplat,n=this._isIdle?o.idleMinimumSplatPixelRadius:o.nonIdleMinimumSplatPixelRadius;this._passParameters.minSplatRadius=n*Math.sqrt(t*e)/Math.sqrt(2073600),r(this._passParameters.origin,this.bindParameters.camera.eye),this._prepareHighPrecisionCameraPosition(),this._updateSlicePlaneLocalOrigin(),this._updateClipUniforms()}_updateClipUniforms(){if(this._clippingEnabled){const[e,t,i,s,a,r]=this._clipBox,[n,h,l]=this.camera.eye;o(this._passParameters.clipMinCameraRelative,e-n,t-h,i-l),o(this._passParameters.clipMaxCameraRelative,s-n,a-h,r-l)}}_updateSlicePlaneLocalOrigin(){this._passParameters.slicePlaneLocalOrigin=this.camera.eye}_hasSameClipBox(e){return d(this._clipBox,e,(e,t)=>e===t)}_renderGaussianColorAndDepth(e,t){const i=this.renderingContext;e.acquireColor(w,5,"gaussian depth output"),i.bindFramebuffer(e.fbo),i.setClearColor(0,0,0,0),i.clear(16384),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(y.TRIANGLE_STRIP,0,4,this._data.visibleGaussians)}_prepareHighPrecisionCameraPosition(){n(this._passParameters.tileCameraPosition,this.camera.eye,1/D.tileSize),h(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),n(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,D.tileSize),l(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this._fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const e=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this._fadeHelper.updateAllTileFading(e),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}static{this.tileSize=2.048}};e([i()],R.prototype,"produces",void 0),e([i()],R.prototype,"consumes",void 0),e([i({constructOnly:!0})],R.prototype,"layerView",void 0),R=D=e([s("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],R);export{R as GaussianSplatRenderNode};
2
+ import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as i,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as r,set as o,scale as n,floor as h,subtract as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as m,set as u,positiveInfinity as c,equals as d}from"../../../../geometry/support/aaBoundingBox.js";import{InternalRenderCategory as _}from"../../webgl.js";import g from"../../webgl/RenderNode.js";import{G as P}from"../../../../chunks/GaussianSplat.glsl.js";import{G as f}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as C}from"../shaders/GaussianSplatCompositionTechnique.js";import{GaussianSplatCompositionTechniqueConfiguration as b}from"../shaders/GaussianSplatCompositionTechniqueConfiguration.js";import{G as S}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as x}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatTechnique as v}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as q}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{ColorAttachment1 as w,DepthStencilAttachment as y,PrimitiveType as D}from"../../../webgl/enums.js";var E;let R=class extends g{static{E=this}constructor(e){super(e),this.produces=_.GAUSSIAN_SPLAT,this.consumes={required:[_.GAUSSIAN_SPLAT]},this._slicePlaneEnabled=!1,this.layerView=null,this._passParameters=new P,this._compositionPassParameters=new f,this._depthCompositionPassParameters=new S,this._compositionConfiguration=new b,this._clipBox=m(),this._previousCameraDirection=p(),this._previousSortRequestCameraDirection=p(),this._sortRequestDirectionEpsilon=.01,this._directionChangeEpsilon=.001,this._configuration=new q(e.view.state.isGlobal),u(this._clipBox,c)}async initialize(){this.addHandles([t(()=>this.view.state.camera,()=>this._onCameraChange()),t(()=>2===this.view.state.mode,()=>this.requestRender(1))])}render(e){const t=e.find(({name:e})=>e===this.produces);if(this._updateConfigurations(),this._handleFading(),!this._data.visibleGaussians||!this._data.orderTexture.texture||!this._data.textureAtlas.texture)return t;const i=t.getAttachment(w);this._compositionConfiguration.hasEmission=null!=i;const s=this.techniques.getCompiled(v,this._configuration),a=this.techniques.getCompiled(C,this._compositionConfiguration),r=this.techniques.getCompiled(x);if(!s||!r||!a)return this.requestRender(1),t;const{fullWidth:o,fullHeight:n}=this.bindParameters.camera;this._prepareParameters(n,o);const h=this.renderingContext,l=this.fboCache,p=l.acquire(o,n,"gaussian color output"),m=t.getAttachment(y);p.attachDepth(m),this._renderGaussianColorAndDepth(p,s);const u=l.acquire(o,n,this.produces);return this._depthCompositionPassParameters.splatDepth=p.getTexture(w),u.attachDepth(t.getAttachment(y)),h.bindFramebuffer(u.fbo),h.bindTechnique(r,this.bindParameters,this._depthCompositionPassParameters),h.screen.draw(),this._compositionPassParameters.color=t.getTexture(),this._compositionPassParameters.splatColor=p.getTexture(),i?(u.acquireColor(w,8,"emissive"),this._compositionPassParameters.emission=t.getTexture(w)):this._compositionPassParameters.emission=null,h.bindFramebuffer(u.fbo),h.bindTechnique(a,this.bindParameters,this._compositionPassParameters),h.screen.draw(),p.release(),u}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this.requestRender(1))}set clippingBox(e){const t=e||c;this._hasSameClipBox(t)||(u(this._clipBox,t),this._data.requestSort(),this.requestRender(1))}get clippingBox(){return this._clippingEnabled?this._clipBox:null}get _clippingEnabled(){return!d(this._clipBox,c,(e,t)=>e===t)}get _isIdle(){return 2===this.view.state.mode}get _data(){return this.layerView.data}get _fadeHelper(){return this.layerView.fadeHelper}_updateConfigurations(){const{idleMinimumOpacity:e,nonIdleMinimumOpacity:t}=this.view.qualitySettings.gaussianSplat;this._configuration.alphaCutoff=this._isIdle?e:t,this._configuration.fadingEnabled=this._fadeHelper.fadingEnabled,this._configuration.receiveShadows=this.bindParameters.shadowMap.ready,this._configuration.hasShadowHighlights=this._configuration.receiveShadows&&this.bindParameters.hasShadowHighlights,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.hasSlicePlane=this._slicePlaneEnabled&&null!=this.bindParameters.slicePlane}destroy(){super.destroy()}_onCameraChange(){const e=this.view.state.camera.ray.direction;if(!this._directionChanged(e))return;if(r(this._previousCameraDirection,e),!this._shouldRequestSort(e))return;this._data.requestSort()&&r(this._previousSortRequestCameraDirection,e)}_directionChanged(e){return Math.abs(e[0]-this._previousCameraDirection[0])>this._directionChangeEpsilon||Math.abs(e[1]-this._previousCameraDirection[1])>this._directionChangeEpsilon||Math.abs(e[2]-this._previousCameraDirection[2])>this._directionChangeEpsilon}_shouldRequestSort(e){return Math.abs(e[0]-this._previousSortRequestCameraDirection[0])>this._sortRequestDirectionEpsilon||Math.abs(e[1]-this._previousSortRequestCameraDirection[1])>this._sortRequestDirectionEpsilon||Math.abs(e[2]-this._previousSortRequestCameraDirection[2])>this._sortRequestDirectionEpsilon}_prepareParameters(e,t){this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture;const i=Math.tan(.5*this.camera.fovY),s=i/e*t;a(this._passParameters.tanFov,s,i),this._passParameters.focalLength=e/(2*i);const o=this.view.qualitySettings.gaussianSplat,n=this._isIdle?o.idleMinimumSplatPixelRadius:o.nonIdleMinimumSplatPixelRadius;this._passParameters.minSplatRadius=n*Math.sqrt(t*e)/Math.sqrt(2073600),r(this._passParameters.origin,this.bindParameters.camera.eye),this._prepareHighPrecisionCameraPosition(),this._updateSlicePlaneLocalOrigin(),this._updateClipUniforms()}_updateClipUniforms(){if(this._clippingEnabled){const[e,t,i,s,a,r]=this._clipBox,[n,h,l]=this.camera.eye;o(this._passParameters.clipMinCameraRelative,e-n,t-h,i-l),o(this._passParameters.clipMaxCameraRelative,s-n,a-h,r-l)}}_updateSlicePlaneLocalOrigin(){this._passParameters.slicePlaneLocalOrigin=this.camera.eye}_hasSameClipBox(e){return d(this._clipBox,e,(e,t)=>e===t)}_renderGaussianColorAndDepth(e,t){const i=this.renderingContext;e.acquireColor(w,5,"gaussian depth output"),i.bindFramebuffer(e.fbo),i.setClearColor(0,0,0,0),i.clear(16384),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(D.TRIANGLE_STRIP,0,4,this._data.visibleGaussians)}_prepareHighPrecisionCameraPosition(){n(this._passParameters.tileCameraPosition,this.camera.eye,1/E.tileSize),h(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),n(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,E.tileSize),l(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this._fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const e=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this._fadeHelper.updateAllTileFading(e),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}static{this.tileSize=2.048}};e([i()],R.prototype,"produces",void 0),e([i()],R.prototype,"consumes",void 0),e([i({constructOnly:!0})],R.prototype,"layerView",void 0),R=E=e([s("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],R);export{R as GaussianSplatRenderNode};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{SliceConfiguration as o}from"../core/shaderLibrary/Slice.glsl.js";import{parameter as i}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";class e extends o{constructor(t){super(),this.spherical=t,this.alphaCutoff=1,this.fadingEnabled=!1,this.clippingEnabled=!1,this.receiveShadows=!1,this.hasShadowHighlights=!1,this.fragmentShadows=!1,this.output=0,this.hasEmission=!1,this.receiveAmbientOcclusion=!1,this.receiveGlobalIllumination=!1,this.pbrMode=0,this.useCustomDTRExponentForWater=!1,this.useFillLights=!1,this.hasColorTexture=!0}}function s(t){switch(t){case 2:return.005;case 0:return.05;default:return.01}}t([i({count:3})],e.prototype,"alphaCutoff",void 0),t([i()],e.prototype,"fadingEnabled",void 0),t([i()],e.prototype,"clippingEnabled",void 0),t([i()],e.prototype,"receiveShadows",void 0),t([i()],e.prototype,"hasShadowHighlights",void 0),t([i()],e.prototype,"fragmentShadows",void 0),t([i({count:12})],e.prototype,"output",void 0),t([i()],e.prototype,"receiveAmbientOcclusion",void 0),t([i()],e.prototype,"receiveGlobalIllumination",void 0);export{e as GaussianSplatTechniqueConfiguration,s as getGaussianSplatAlphaCutoffValue};
2
+ import{__decorate as t}from"tslib";import{SliceConfiguration as i}from"../core/shaderLibrary/Slice.glsl.js";import{parameter as e}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";class o extends i{constructor(t){super(),this.spherical=t,this.alphaCutoff=1,this.fadingEnabled=!1,this.clippingEnabled=!1,this.receiveShadows=!1,this.hasShadowHighlights=!1,this.output=0,this.hasEmission=!1,this.receiveAmbientOcclusion=!1,this.receiveGlobalIllumination=!1,this.pbrMode=0,this.useCustomDTRExponentForWater=!1,this.useFillLights=!1,this.hasColorTexture=!0}}function r(t){switch(t){case 3:return.005;case 2:return.025;case 0:return.05;default:return.01}}t([e({count:4})],o.prototype,"alphaCutoff",void 0),t([e()],o.prototype,"fadingEnabled",void 0),t([e()],o.prototype,"clippingEnabled",void 0),t([e()],o.prototype,"receiveShadows",void 0),t([e()],o.prototype,"hasShadowHighlights",void 0),t([e({count:12})],o.prototype,"output",void 0),t([e()],o.prototype,"receiveAmbientOcclusion",void 0),t([e()],o.prototype,"receiveGlobalIllumination",void 0);export{o as GaussianSplatTechniqueConfiguration,r as getGaussianSplatAlphaCutoffValue};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/Float4PassUniform.js";import"../core/shaderModules/glsl.js";import"./OutputColorHighlightOLID.glsl.js";import"../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../chunks/NativeLine.glsl.js";
2
+ import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js";import"../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/Float4PassUniform.js";import"../core/shaderModules/glsl.js";import"./OutputColorHighlightOLID.glsl.js";import"../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../chunks/NativeLine.glsl.js";
@@ -1,12 +1,13 @@
1
1
  import type Graphic from "../../Graphic.js";
2
2
  import type EsriMap from "../../Map.js";
3
3
  import type Collection from "../../core/Collection.js";
4
+ import type AttachmentInfo from "../../rest/query/support/AttachmentInfo.js";
4
5
  import type BatchFormInputs from "./inputs/BatchFormInputs.js";
5
6
  import type FieldInput from "./inputs/FieldInput.js";
6
7
  import type { EventedAccessor } from "../../core/Evented.js";
7
8
  import type { FieldValue } from "../../layers/support/fieldUtils.js";
8
9
  import type { TimeZone } from "../../time/types.js";
9
- import type { AttributeFormSupportedLayerInfo, AttributeFormSupportedLayerUnion, BatchAttributeFormMode, BatchAttributeFormState, ValueChangeEvent, SubmitEvent } from "./types.js";
10
+ import type { AttachmentsChangeEvent, AttributeFormSupportedLayerInfo, AttributeFormSupportedLayerUnion, BatchAttributeFormMode, BatchAttributeFormState, ValueChangeEvent, SubmitEvent } from "./types.js";
10
11
  import type { FormInput } from "./inputs/types.js";
11
12
  import type { EditType } from "../support/forms/types.js";
12
13
 
@@ -27,6 +28,12 @@ export interface BatchAttributeFormViewModelEvents {
27
28
  * });
28
29
  */
29
30
  "value-change": ValueChangeEvent;
31
+ /**
32
+ * Fires when staged attachment edits are updated.
33
+ *
34
+ * @since 5.1
35
+ */
36
+ "attachments-change": AttachmentsChangeEvent;
30
37
  /** Fires when the [BatchAttributeForm.submit()](https://developers.arcgis.com/javascript/latest/references/core/widgets/BatchAttributeForm/#submit) method is called. */
31
38
  submit: SubmitEvent;
32
39
  }
@@ -239,6 +246,11 @@ export default class BatchAttributeFormViewModel extends EventedAccessor {
239
246
  * This array includes only those inputs that are not hidden by visibility settings or expressions.
240
247
  */
241
248
  get visibleInputs(): FormInput[];
249
+ /**
250
+ * @param elementId - Attachment element identifier.
251
+ * @internal
252
+ */
253
+ clearAttachmentChanges(elementId: string): void;
242
254
  /**
243
255
  * Finds the field input with the specified `elementId` in the active form.
244
256
  *
@@ -260,6 +272,33 @@ export default class BatchAttributeFormViewModel extends EventedAccessor {
260
272
  * @returns The current attribute values for the given feature.
261
273
  */
262
274
  getValues(feature: Graphic): Graphic["attributes"];
275
+ /**
276
+ * @param elementId - Attachment element identifier.
277
+ * @param files - Files to stage for addition.
278
+ * @returns The attachments staged for addition.
279
+ * @internal
280
+ */
281
+ stageAddAttachments(elementId: string, files: (Blob | File)[]): Promise<AttachmentInfo[]>;
282
+ /**
283
+ * @param elementId - Attachment element identifier.
284
+ * @param attachmentGlobalId - Global identifier of the attachment to stage for deletion.
285
+ * @internal
286
+ */
287
+ stageDeleteAttachment(elementId: string, attachmentGlobalId: string): void;
288
+ /**
289
+ * @param elementId - Attachment element identifier.
290
+ * @param attachmentGlobalId - Global identifier of the attachment to rename.
291
+ * @param name - New attachment name.
292
+ * @internal
293
+ */
294
+ stageRenameAttachment(elementId: string, attachmentGlobalId: string, name: string): void;
295
+ /**
296
+ * @param elementId - Attachment element identifier.
297
+ * @param attachmentGlobalId - Global identifier of the attachment to replace.
298
+ * @param file - File contents for the replacement attachment.
299
+ * @internal
300
+ */
301
+ stageReplaceAttachment(elementId: string, attachmentGlobalId: string, file: Blob | File): Promise<void>;
263
302
  /**
264
303
  * This method triggers the `"submit"` event, and causes [submitHasBeenAttempted](https://developers.arcgis.com/javascript/latest/references/core/widgets/BatchAttributeForm/BatchAttributeFormViewModel/#submitHasBeenAttempted) to become `true`. It does _not_ do anything to persist the updated values. It is up to the client to verify if these values are appropriate. For example, calling [FeatureLayer.applyEdits()](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#applyEdits) method to update the features' attributes.
265
304
  *
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{createTask as t}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import r from"../../core/Error.js";import{EventedAccessor as i}from"../../core/Evented.js";import a from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{abortMaybe as n,destroyMaybe as p}from"../../core/maybe.js";import{throwIfAborted as l,isAbortError as u}from"../../core/promiseUtils.js";import h from"../../core/ReactiveMap.js";import{on as m,sync as c,watch as d,whenOnce as f}from"../../core/reactiveUtils.js";import{property as y,subclass as v}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import F from"../../geometry/SpatialReference.js";import{getGraphicLayer as _}from"../../graphic/graphicOriginUtils.js";import{system as x}from"../../time/constants.js";import{createReactiveGraphic as w,isAttributeFormSupportedLayerWithAttachments as I,layerSupportsQueryAttachments as b,queryAttachmentsForElements as A}from"./batchAttributeFormUtils.js";import{ArcadeExecutorProvider as M}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as k}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as C}from"./expressions/ExpressionsModel.js";import E from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as T}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as V,isFieldInput as j}from"./inputs/support/inputUtils.js";import L from"./templates/BatchFormTemplate.js";import{getLayerContingentValuesMetaData as H}from"./templates/support/contingentValuesUtils.js";import{createBatchFormTemplate as B}from"./templates/support/createBatchFormTemplate.js";import{isExcludedFromSharedForm as G,isGroupElementTemplate as R}from"./templates/support/templateUtils.js";function U(e,t){return e?.find(e=>e.layer===t)}let Z=class extends i{constructor(e){super(e),this._attachmentCache=new h,this.activeFeatureIndex=-1,this.disabled=!1,this.editType="NA",this.features=new s,this._hasAsyncArcadeExpressions=!1,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.map=null,this.readOnly=!1,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this.layerInfos=null,this._arcadeExecutorProvider=new M,this._activeFormInputsByElementId=new Map,this._emptyForm=new E({inputs:[]}),this._emptyFormTemplate=new L({elements:[]}),this._featureFormMap=new Map,this._prepareTask=null,this._reactiveGraphicLookup=new h,this._updatingHandles=new g,this._layerTemplateMap=new h,this._layerContingentValuesMap=new h,this._workingFeatures=new s,this._expressionsManager=new k({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:x}}),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.addHandles([m(()=>this.features,"after-changes",()=>{this.notifyChange("layers"),this._prepare()},c),d(()=>[this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),c),d(()=>this.activeForm,()=>this._activeFormInputsByElementId.clear(),c),d(()=>[this.activeFeature,this.activeLayer,this.activeForm],()=>{this._syncAttachments()},c)]),this._prepare()}destroy(){this._prepareTask=n(this._prepareTask),this._workingFeatures.destroyAll(),p(this._expressionsManager),this._updatingHandles.destroy(),this._reactiveGraphicLookup=new h,this._emptyForm.destroy(),this._emptyFormTemplate.destroy()}get _effectiveTimeZone(){return this.timeZone??"system"}get activeFeature(){const e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;const t=this._featureFormMap.get(e);if(t)return t;const s=this._makeBatchFormInputsForFeature(e);return s!==this._emptyForm&&this._featureFormMap.set(e,s),s}get activeLayer(){const{activeFeature:e}=this;if(!e)return null;return _(e)??null}get calculating(){return this._expressionsManager.calculating}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if("batch"===this.mode)return!1;const{activeFeature:e}=this;return this.invalidFeatures.some(t=>t!==e)}get hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){for(const e of this.layers){const t=this._layerContingentValuesMap.get(e);if(t&&t.size>0)return!0}return!1}get visibleInputs(){return this.activeForm.inputs.filter(e=>e.visible)}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(0===this.activeForm.inputs.length)return"noElements";const e=new Set;for(const t of this.activeForm.inputs)switch(t.visibilityCode){case"hidden:not-in-all-layers":case"hidden:no-domain-in-common":e.add("noElementsInCommon");break;case"hidden:field-definition":case"hidden:group-visibility-expression:all-features":case"hidden:visibility-expression:all-features":e.add("allElementsHidden");break;case"hidden:group-visibility-expression:some-features":case"hidden:visibility-expression:some-features":return"elementsHiddenInSome"}return e.has("allElementsHidden")?"allElementsHidden":"noElementsInCommon"}get status(){const e=this._prepareTask;return null==e?"not-loaded":e.finished?null!=e.error?"failed":"loaded":"loading"}get submittable(){return this.valid,!0}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid}get layers(){const e=new Set;return this.features.forEach(t=>{const s=_(t);s&&e.add(s)}),Array.from(e)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){this.submitHasBeenAttempted=!0,this.emit("submit",{name:"submit",results:this._makeSubmitResults(),valid:this.valid})}findFieldInput(e){if(null==e)return;const t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);const s=this.activeForm.allFieldInputs.find(t=>t.template.elementId===e);return void 0!==s?(t.set(e,s),s):void 0}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(const e of this.visibleInputs){if(V(e)){const t=e.inputs.find(e=>j(e)&&!e.valid);if(t)return{input:t,groupInput:e}}if(j(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){const t=this._reactiveGraphicLookup.get(e);if(!t)throw new r("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}notifyGeometriesChanged(e){const t=[];for(const s of e){const e=this._reactiveGraphicLookup.get(s);e&&(t.push(e),e.geometry=s.geometry)}this._expressionsManager.runGeometryDependentExpressions(t)}async setFieldInputValue(e,t){const s=new Set(this.invalidFeatures);await e.setValueFromUser(t),this.userHasChangedValues=!0,this._trackValidityChange(s),this.emit("value-change",{features:e.features.toArray().map(e=>e.source),fieldName:e.fieldName,name:"value-change",value:t})}async setValue(e,t){const s=this.findFieldInput(e);if(null==s)throw new r("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);await this.setFieldInputValue(s,t)}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}async _trackValidityChange(e){await f(()=>!1===this.calculating);const t=this.invalidFeatures;for(const s of t)!1===e.has(s)&&this._reactiveGraphicLookup.has(s)&&(this._reactiveGraphicLookup.get(s).userChangesHaveMadeInvalid=!0)}validate(){return!1}_makeBatchFormInputsForFeature(e){const t=this._layerTemplateMap.get(e.layer);return t?T(t,new s([e]),this._expressionsManager):this._emptyForm}_makeSubmitResults(){const e=new Map;for(const[t,s]of this._reactiveGraphicLookup)e.set(t,{feature:t,values:{...s.attributes},invalidFields:[]});for(const t of this.sharedForm.allFieldInputs)for(const s of t.invalidFeatures)e.get(s)?.invalidFields.push(t.fieldName);return Array.from(e.values())}_prepare(){this._hasAsyncArcadeExpressions=!1,this._prepareTask=n(this._prepareTask),this._updateWorkingFeatures(),p(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new k({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??F.WebMercator,map:this.map,timeZone:this._effectiveTimeZone}});const{layers:e}=this;if(0===e.length)return;const s=t(async t=>{try{l(t);const s=new Map;for(const r of e){const e=await H(r);if(l(t),e){const t=e.fieldGroups.flatMap(e=>e.fields);this._layerContingentValuesMap.set(r,new Set(t))}else this._layerContingentValuesMap.set(r,new Set);const i=U(this.layerInfos,r),a=await B(r,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this._effectiveTimeZone},i?.formTemplate);l(t),this._layerTemplateMap.set(r,a);const o=a.getExpressionExecutorsForLayer(r);if(this._expressionsManager.layerExpressionsModelMap.set(r,new C({preserveFieldValuesWhenHidden:a.preserveFieldValuesWhenHidden,executorMap:o})),!this._hasAsyncArcadeExpressions)for(const t of o.keys()){const e=o.get(t);if(this._hasAsyncArcadeExpressions=!0===(e.editableExpression?.isAsync||e.requiredExpression?.isAsync||e.valueExpression?.isAsync||e.visibilityExpression?.isAsync),this._hasAsyncArcadeExpressions)break}for(const t of a.elements){if(G(t))continue;const e=t.clone();R(e)&&(e.elements=e.elements.filter(e=>!G(e)));const{elementId:r}=e;s.has(r)?s.get(r).foldIn(e):s.set(r,e)}}if(this.hasTooManyComplexFeatures)throw new r("too-many-features-with-complex-forms","There are too many features to load into the form with the configured complexity");if(this.hasTooManyFeatures)throw new r("too-many-features","There are too many features to load into the form.");const i=new L({elements:Array.from(s.values())});this.sharedFormTemplate=i,this.sharedForm=T(i,this._workingFeatures,this._expressionsManager),await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray())}catch(s){throw u(s)||a.getLogger(this).error("Failed preparing form",s),s}});this._updatingHandles.consumePromise(s.promise),this._prepareTask=s}_updateWorkingFeatures(){this._workingFeatures.destroyAll();const{features:e}=this;if(this._reactiveGraphicLookup=new h,0!==e.length){this._workingFeatures.addMany(e.map(w));for(const e of this._workingFeatures)this._reactiveGraphicLookup.set(e.source,e)}}async _syncAttachments(){const{activeFeature:e,activeLayer:t,activeForm:s}=this;if(!(e&&s&&I(t)&&b(t)))return;const r=e.getObjectId();if(null==r)return;const i=this._attachmentCache.get(t),a=s.allAttachmentElementInputs;if(!a.length)return;let n;if(i){const e=i.get(r);e&&(n=e)}if(!n){n=await A(t,r,a);o(this._attachmentCache,t,()=>new h).set(r,n)}for(const o of a)o.attachments=W(o,n)}};e([y()],Z.prototype,"_effectiveTimeZone",null),e([y()],Z.prototype,"_attachmentCache",void 0),e([y({readOnly:!0})],Z.prototype,"activeFeature",null),e([y()],Z.prototype,"activeFeatureIndex",void 0),e([y({readOnly:!0})],Z.prototype,"activeForm",null),e([y({readOnly:!0})],Z.prototype,"activeLayer",null),e([y()],Z.prototype,"disabled",void 0),e([y()],Z.prototype,"calculating",null),e([y()],Z.prototype,"editType",void 0),e([y()],Z.prototype,"features",void 0),e([y()],Z.prototype,"expressionEvaluationFailed",null),e([y()],Z.prototype,"hasNonActiveInvalidFeatures",null),e([y()],Z.prototype,"hasAsyncArcadeExpressions",null),e([y()],Z.prototype,"_hasAsyncArcadeExpressions",void 0),e([y()],Z.prototype,"invalidFeatures",null),e([y()],Z.prototype,"hasVisibleInputs",null),e([y()],Z.prototype,"hasLayersWithContingentValues",null),e([y()],Z.prototype,"maximumFeatureCount",void 0),e([y()],Z.prototype,"maximumFeatureCountWithComplexForms",void 0),e([y()],Z.prototype,"visibleInputs",null),e([y()],Z.prototype,"map",void 0),e([y()],Z.prototype,"noVisibleElementsReason",null),e([y()],Z.prototype,"readOnly",void 0),e([y()],Z.prototype,"spatialReference",void 0),e([y()],Z.prototype,"submitHasBeenAttempted",void 0),e([y()],Z.prototype,"timeZone",void 0),e([y()],Z.prototype,"updating",null),e([y()],Z.prototype,"valid",null),e([y()],Z.prototype,"layers",null),e([y()],Z.prototype,"mode",null),e([y()],Z.prototype,"sharedForm",void 0),e([y()],Z.prototype,"sharedFormTemplate",void 0),e([y()],Z.prototype,"userHasChangedValues",void 0),e([y()],Z.prototype,"layerInfos",void 0),e([y()],Z.prototype,"_arcadeExecutorProvider",void 0),e([y()],Z.prototype,"_prepareTask",void 0),e([y()],Z.prototype,"_reactiveGraphicLookup",void 0),e([y()],Z.prototype,"_layerTemplateMap",void 0),e([y()],Z.prototype,"_layerContingentValuesMap",void 0),e([y()],Z.prototype,"_workingFeatures",void 0),e([y()],Z.prototype,"_expressionsManager",void 0),Z=e([v("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],Z);const S=Z;function W(e,t){const s="attachment"===e.input?.type?e.input.attachmentAssociationType:"exact",r=e.attachmentKeyword,i=null!=r&&r.length>0;if("any"===s)return t;if("exactOrNone"===s){if(!i)return t.filter(e=>O(e.keywords));const e=r.toLowerCase();return t.filter(t=>O(t.keywords)||P(t,e))}if(!i)return t;const a=r.toLowerCase();return t.filter(e=>P(e,a))}function N(e){return null!=e&&e.trim().length>0}function O(e){return!N(e)}function P(e,t){const s=e.keywords;return null!=s&&s.toLowerCase()===t.toLowerCase()}export{S as default};
2
+ import{__decorate as e}from"tslib";import{pushIfSome as t}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{abortMaybe as h,destroyMaybe as p}from"../../core/maybe.js";import{throwIfAborted as l,isAbortError as u}from"../../core/promiseUtils.js";import m from"../../core/ReactiveMap.js";import{on as c,sync as d,watch as f,whenOnce as y}from"../../core/reactiveUtils.js";import{property as g,subclass as v}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as _}from"../../core/support/UpdatingHandles.js";import F from"../../geometry/SpatialReference.js";import{getGraphicLayer as A}from"../../graphic/graphicOriginUtils.js";import{system as x}from"../../time/constants.js";import{createReactiveGraphic as w,isAttributeFormSupportedLayerWithAttachments as I,layerSupportsQueryAttachments as C,queryAttachmentsForElements as E}from"./batchAttributeFormUtils.js";import{ArcadeExecutorProvider as M}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as b}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as k}from"./expressions/ExpressionsModel.js";import T from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as V}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as j,isFieldInput as H}from"./inputs/support/inputUtils.js";import L from"./templates/BatchFormTemplate.js";import{getLayerContingentValuesMetaData as B}from"./templates/support/contingentValuesUtils.js";import{createBatchFormTemplate as R}from"./templates/support/createBatchFormTemplate.js";import{isExcludedFromSharedForm as G,isGroupElementTemplate as U}from"./templates/support/templateUtils.js";import{isEmptyValue as S}from"../support/forms/formUtils.js";function Z(e,t){return e?.find(e=>e.layer===t)}let W=class extends a{constructor(e){super(e),this._attachmentCache=new m,this.activeFeatureIndex=-1,this.disabled=!1,this.editType="NA",this.features=new r,this._hasAsyncArcadeExpressions=!1,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.map=null,this.readOnly=!1,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this.layerInfos=null,this._arcadeExecutorProvider=new M,this._activeFormInputsByElementId=new Map,this._emptyForm=new T({inputs:[]}),this._emptyFormTemplate=new L({elements:[]}),this._featureFormMap=new Map,this._prepareTask=null,this._reactiveGraphicLookup=new m,this._updatingHandles=new _,this._layerTemplateMap=new m,this._layerContingentValuesMap=new m,this._workingFeatures=new r,this._expressionsManager=new b({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:x}}),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.addHandles([c(()=>this.features,"after-changes",()=>{this.notifyChange("layers"),this._prepare()},d),f(()=>[this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),d),f(()=>this.activeForm,()=>this._activeFormInputsByElementId.clear(),d),f(()=>[this.activeFeature,this.activeLayer,this.activeForm],()=>{this._syncAttachments()},d)]),this._prepare()}destroy(){this._prepareTask=h(this._prepareTask),this._workingFeatures.destroyAll(),p(this._expressionsManager),this._updatingHandles.destroy(),this._reactiveGraphicLookup=new m,this._emptyForm.destroy(),this._emptyFormTemplate.destroy()}get _effectiveTimeZone(){return this.timeZone??"system"}get activeFeature(){const e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;const t=this._featureFormMap.get(e);if(t)return t;const s=this._makeBatchFormInputsForFeature(e);return s!==this._emptyForm&&this._featureFormMap.set(e,s),s}get activeLayer(){const{activeFeature:e}=this;if(!e)return null;return A(e)??null}get calculating(){return this._expressionsManager.calculating}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if("batch"===this.mode)return!1;const{activeFeature:e}=this;return this.invalidFeatures.some(t=>t!==e)}get hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){for(const e of this.layers){const t=this._layerContingentValuesMap.get(e);if(t&&t.size>0)return!0}return!1}get visibleInputs(){return this.activeForm.inputs.filter(e=>e.visible)}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(0===this.activeForm.inputs.length)return"noElements";const e=new Set;for(const t of this.activeForm.inputs)switch(t.visibilityCode){case"hidden:not-in-all-layers":case"hidden:no-domain-in-common":e.add("noElementsInCommon");break;case"hidden:field-definition":case"hidden:group-visibility-expression:all-features":case"hidden:visibility-expression:all-features":e.add("allElementsHidden");break;case"hidden:group-visibility-expression:some-features":case"hidden:visibility-expression:some-features":return"elementsHiddenInSome"}return e.has("allElementsHidden")?"allElementsHidden":"noElementsInCommon"}get status(){const e=this._prepareTask;return null==e?"not-loaded":e.finished?null!=e.error?"failed":"loaded":"loading"}get submittable(){return this.valid,!0}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid&&Array.from(this._featureFormMap.values()).every(e=>e.valid)}get layers(){const e=new Set;return this.features.forEach(t=>{const s=A(t);s&&e.add(s)}),Array.from(e)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){this.submitHasBeenAttempted=!0,this.emit("submit",{name:"submit",results:this._makeSubmitResults(),valid:this.valid})}findFieldInput(e){if(null==e)return;const t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);const s=this.activeForm.allFieldInputs.find(t=>t.template.elementId===e);return void 0!==s?(t.set(e,s),s):void 0}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(const e of this.visibleInputs){if(j(e)){const t=e.inputs.find(e=>H(e)&&!e.valid);if(t)return{input:t,groupInput:e}}if(H(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){const t=this._reactiveGraphicLookup.get(e);if(!t)throw new i("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}notifyGeometriesChanged(e){const t=[];for(const s of e){const e=this._reactiveGraphicLookup.get(s);e&&(t.push(e),e.geometry=s.geometry)}this._expressionsManager.runGeometryDependentExpressions(t)}async setFieldInputValue(e,t){const s=new Set(this.invalidFeatures);await e.setValueFromUser(t),this.userHasChangedValues=!0,this._trackValidityChange(s),this.emit("value-change",{features:e.features.toArray().map(e=>e.source),fieldName:e.fieldName,name:"value-change",value:t})}async setValue(e,t){const s=this.findFieldInput(e);if(null==s)throw new i("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);await this.setFieldInputValue(s,t)}async stageAddAttachments(e,t){if(0===t.length)return[];const s=this._findAttachmentInput(e);if(!s)return[];const r=await s.stageAddAttachments(t,this._expressionsManager.arcadeContext);return this.userHasChangedValues=!0,this._emitAttachmentsChange(s),r}stageDeleteAttachment(e,t){const s=this._findAttachmentInput(e);if(!s)return;const r=this._findAttachment(s,t);r&&(s.stageDeleteAttachment(r),this.userHasChangedValues=!0,this._emitAttachmentsChange(s))}stageRenameAttachment(e,t,s){const r=this._findAttachmentInput(e);if(!r)return;const i=this._findAttachment(r,t);i&&0!==s.trim().length&&(r.stageRenameAttachment(i,s.trim()),this.userHasChangedValues=!0,this._emitAttachmentsChange(r))}async stageReplaceAttachment(e,t,s){const r=this._findAttachmentInput(e);if(!r)return;const i=this._findAttachment(r,t);i&&(await r.stageReplaceAttachment(i,s,this._expressionsManager.arcadeContext),this.userHasChangedValues=!0,this._emitAttachmentsChange(r))}clearAttachmentChanges(e){const t=this._findAttachmentInput(e);t&&(t.clearAttachmentChanges(),this._emitAttachmentsChange(t))}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}async _trackValidityChange(e){await y(()=>!1===this.calculating);const t=this.invalidFeatures;for(const s of t)!1===e.has(s)&&this._reactiveGraphicLookup.has(s)&&(this._reactiveGraphicLookup.get(s).userChangesHaveMadeInvalid=!0)}validate(){return!1}_makeBatchFormInputsForFeature(e){const t=this._layerTemplateMap.get(e.layer);return t?V(t,new r([e]),this._expressionsManager):this._emptyForm}_makeSubmitResults(){const e=new Map;for(const[s,r]of this._reactiveGraphicLookup){const i=[],a=[],n=this._featureFormMap.get(r)?.allAttachmentElementInputs??[];for(const e of n)t(i,e.toSubmitEdits()),e.valid||a.push(e.template.elementId);e.set(s,{feature:s,values:{...r.attributes},invalidFields:[],attachmentEdits:i,invalidAttachmentElementIds:a})}for(const t of this.sharedForm.allFieldInputs)for(const s of t.invalidFeatures)e.get(s)?.invalidFields.push(t.fieldName);return Array.from(e.values())}_findAttachmentInput(e){const t=this.activeForm.allAttachmentElementInputs.find(t=>t.template.elementId===e);return t||n.getLogger(this).error(`Attachment input not found for elementId '${e}'`),t}_findAttachment(e,t){const s=e.findAttachment(t);return s||n.getLogger(this).error(`Attachment '${t}' not found for attachment element '${e.template.elementId}'`),s}_makeAttachmentEdits(e){const s=[];for(const r of e.allAttachmentElementInputs)t(s,r.toSubmitEdits());return s}_emitAttachmentsChange(e){const t=e.single.feature;if(!t)return;const s=this._featureFormMap.get(t);this.emit("attachments-change",{name:"attachments-change",feature:t.source,attachmentEdits:this._makeAttachmentEdits(s??this.activeForm),valid:this.valid})}_prepare(){this._hasAsyncArcadeExpressions=!1,this._prepareTask=h(this._prepareTask),this._updateWorkingFeatures(),p(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new b({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??F.WebMercator,map:this.map,timeZone:this._effectiveTimeZone}});const{layers:e}=this;if(0===e.length)return;const t=s(async t=>{try{l(t);const s=new Map;for(const i of e){const e=await B(i);if(l(t),e){const t=e.fieldGroups.flatMap(e=>e.fields);this._layerContingentValuesMap.set(i,new Set(t))}else this._layerContingentValuesMap.set(i,new Set);const r=Z(this.layerInfos,i),a=await R(i,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this._effectiveTimeZone},r?.formTemplate);l(t),this._layerTemplateMap.set(i,a);const n=a.getExpressionExecutorsForLayer(i);if(this._expressionsManager.layerExpressionsModelMap.set(i,new k({preserveFieldValuesWhenHidden:a.preserveFieldValuesWhenHidden,executorMap:n})),!this._hasAsyncArcadeExpressions)for(const t of n.keys()){const e=n.get(t);if(this._hasAsyncArcadeExpressions=!0===(e.editableExpression?.isAsync||e.requiredExpression?.isAsync||e.valueExpression?.isAsync||e.visibilityExpression?.isAsync),this._hasAsyncArcadeExpressions)break}for(const t of a.elements){if(G(t))continue;const e=t.clone();U(e)&&(e.elements=e.elements.filter(e=>!G(e)));const{elementId:r}=e;s.has(r)?s.get(r).foldIn(e):s.set(r,e)}}if(this.hasTooManyComplexFeatures)throw new i("too-many-features-with-complex-forms","There are too many features to load into the form with the configured complexity");if(this.hasTooManyFeatures)throw new i("too-many-features","There are too many features to load into the form.");const r=new L({elements:Array.from(s.values())});this.sharedFormTemplate=r,this.sharedForm=V(r,this._workingFeatures,this._expressionsManager),await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray())}catch(s){throw u(s)||n.getLogger(this).error("Failed preparing form",s),s}});this._updatingHandles.consumePromise(t.promise),this._prepareTask=t}_updateWorkingFeatures(){this._workingFeatures.destroyAll();for(const t of this._featureFormMap.values())t.destroy();this._featureFormMap.clear(),this._attachmentCache.clear();const{features:e}=this;if(this._reactiveGraphicLookup=new m,0!==e.length){this._workingFeatures.addMany(e.map(w));for(const e of this._workingFeatures)this._reactiveGraphicLookup.set(e.source,e)}}async _syncAttachments(){const{activeFeature:e,activeLayer:t,activeForm:s}=this;if(!(e&&s&&I(t)&&C(t)))return;const r=e.getObjectId();if(null==r)return;const i=this._attachmentCache.get(t),a=s.allAttachmentElementInputs;if(!a.length)return;let n;if(i){const e=i.get(r);e&&(n=e)}if(!n){n=await E(t,r,a);o(this._attachmentCache,t,()=>new m).set(r,n)}for(const o of a)o.applyFetchedAttachments(D(o,n))}};e([g()],W.prototype,"_effectiveTimeZone",null),e([g()],W.prototype,"_attachmentCache",void 0),e([g({readOnly:!0})],W.prototype,"activeFeature",null),e([g()],W.prototype,"activeFeatureIndex",void 0),e([g({readOnly:!0})],W.prototype,"activeForm",null),e([g({readOnly:!0})],W.prototype,"activeLayer",null),e([g()],W.prototype,"disabled",void 0),e([g()],W.prototype,"calculating",null),e([g()],W.prototype,"editType",void 0),e([g()],W.prototype,"features",void 0),e([g()],W.prototype,"expressionEvaluationFailed",null),e([g()],W.prototype,"hasNonActiveInvalidFeatures",null),e([g()],W.prototype,"hasAsyncArcadeExpressions",null),e([g()],W.prototype,"_hasAsyncArcadeExpressions",void 0),e([g()],W.prototype,"invalidFeatures",null),e([g()],W.prototype,"hasVisibleInputs",null),e([g()],W.prototype,"hasLayersWithContingentValues",null),e([g()],W.prototype,"maximumFeatureCount",void 0),e([g()],W.prototype,"maximumFeatureCountWithComplexForms",void 0),e([g()],W.prototype,"visibleInputs",null),e([g()],W.prototype,"map",void 0),e([g()],W.prototype,"noVisibleElementsReason",null),e([g()],W.prototype,"readOnly",void 0),e([g()],W.prototype,"spatialReference",void 0),e([g()],W.prototype,"submitHasBeenAttempted",void 0),e([g()],W.prototype,"timeZone",void 0),e([g()],W.prototype,"updating",null),e([g()],W.prototype,"valid",null),e([g()],W.prototype,"layers",null),e([g()],W.prototype,"mode",null),e([g()],W.prototype,"sharedForm",void 0),e([g()],W.prototype,"sharedFormTemplate",void 0),e([g()],W.prototype,"userHasChangedValues",void 0),e([g()],W.prototype,"layerInfos",void 0),e([g()],W.prototype,"_arcadeExecutorProvider",void 0),e([g()],W.prototype,"_prepareTask",void 0),e([g()],W.prototype,"_reactiveGraphicLookup",void 0),e([g()],W.prototype,"_layerTemplateMap",void 0),e([g()],W.prototype,"_layerContingentValuesMap",void 0),e([g()],W.prototype,"_workingFeatures",void 0),e([g()],W.prototype,"_expressionsManager",void 0),W=e([v("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],W);const N=W;function O(e){return null!=e&&e.trim().length>0}function P(e,t){const s=e.keywords;return O(s)&&s.toLowerCase()===t}function D(e,t){const s="attachment"===e.input?.type?e.input.attachmentAssociationType:"exact",r=e.attachmentKeyword;if("any"===s)return t;if("exactOrNone"===s){if(S(r))return t.filter(e=>!O(e.keywords));const e=r.toLowerCase();return t.filter(t=>!O(t.keywords)||P(t,e))}if(S(r))return t;const i=r.toLowerCase();return t.filter(e=>P(e,i))}export{N as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import r from"../../core/Accessor.js";import{createObservableProxy as e}from"../../core/proxy.js";import{property as o,subclass as s}from"../../core/accessorSupport/decorators.js";import{valuesAreEquivalent as i}from"../support/forms/formUtils.js";let a=class extends r{constructor(t){super(t),this.userChangesHaveMadeInvalid=!1,this.original=t.source.clone();const r=t.source.attributes??{},o=e({...r});this.attributes=o;const s=t.source.cloneShallow();s.attributes=o,this.plainGraphic=s}get geometry(){return this.plainGraphic.geometry}set geometry(t){this.plainGraphic.geometry=t}get layer(){return this.source.sourceLayer??this.source.layer}attributeHasChanged(t){return!i(this.attributes[t],this.original.attributes?.[t])}getAttribute(t){return this.attributes[t]??null}setAttribute(t,r){this.attributes[t]=r}};t([o()],a.prototype,"attributes",void 0),t([o()],a.prototype,"geometry",null),t([o()],a.prototype,"plainGraphic",void 0),t([o()],a.prototype,"layer",null),t([o({constructOnly:!0})],a.prototype,"original",void 0),t([o({constructOnly:!0})],a.prototype,"source",void 0),t([o()],a.prototype,"userChangesHaveMadeInvalid",void 0),a=t([s("esri.widgets.BatchAttributeForm.ReactiveGraphic")],a);export{a as ReactiveGraphic};
2
+ import{__decorate as t}from"tslib";import r from"../../core/Accessor.js";import{createObservableProxy as e}from"../../core/proxy.js";import{property as o,subclass as i}from"../../core/accessorSupport/decorators.js";import{valuesAreEquivalent as s}from"../support/forms/formUtils.js";let a=class extends r{constructor(t){super(t),this.userChangesHaveMadeInvalid=!1,this.original=t.source.clone();const r=t.source.attributes??{},o=e({...r});this.attributes=o;const i=t.source.cloneShallow();i.attributes=o,this.plainGraphic=i}get geometry(){return this.plainGraphic.geometry}set geometry(t){this.plainGraphic.geometry=t}get layer(){return this.source.sourceLayer??this.source.layer}attributeHasChanged(t){return!s(this.attributes[t],this.original.attributes?.[t])}getAttribute(t){return this.attributes[t]??null}getObjectId(){return this.plainGraphic.getObjectId()}getGlobalId(){return this.plainGraphic.getGlobalId()}setAttribute(t,r){this.attributes[t]=r}};t([o()],a.prototype,"attributes",void 0),t([o()],a.prototype,"geometry",null),t([o()],a.prototype,"plainGraphic",void 0),t([o()],a.prototype,"layer",null),t([o({constructOnly:!0})],a.prototype,"original",void 0),t([o({constructOnly:!0})],a.prototype,"source",void 0),t([o()],a.prototype,"userChangesHaveMadeInvalid",void 0),a=t([i("esri.widgets.BatchAttributeForm.ReactiveGraphic")],a);export{a as ReactiveGraphic};
@@ -0,0 +1 @@
1
+ export interface ArcadeBatchFormCalculationContextInfo {}
@@ -3,7 +3,8 @@ import type AttachmentInfo from "../../../rest/query/support/AttachmentInfo.js";
3
3
  import type EditableInput from "./EditableInput.js";
4
4
  import type GroupInput from "./GroupInput.js";
5
5
  import type { AttachmentInputUnion } from "../../../form/elements/inputs/attachments/types.js";
6
- import type { AttributeFormSupportedLayerUnion } from "../types.js";
6
+ import type { AttributeFormSupportedLayerUnion, PendingAttachmentEdits } from "../types.js";
7
+ import type { ArcadeBatchFormCalculationContextInfo } from "../expressions/types.js";
7
8
  import type { EditableInputProperties } from "./EditableInput.js";
8
9
 
9
10
  /** @since 5.1 */
@@ -61,4 +62,54 @@ export default class AttachmentElementInput extends EditableInput<any> {
61
62
  get type(): "attachment";
62
63
  /** Indicates if the original filename should be used when creating attachments. */
63
64
  get useOriginalFilename(): boolean | null | undefined;
65
+ /**
66
+ * @param attachments - Attachments fetched from the service for this input.
67
+ * @internal
68
+ */
69
+ applyFetchedAttachments(attachments: AttachmentInfo[]): void;
70
+ /** @internal */
71
+ clearAttachmentChanges(): void;
72
+ /**
73
+ * @param attachmentGlobalId - Global identifier of the attachment to retrieve.
74
+ * @internal
75
+ */
76
+ findAttachment(attachmentGlobalId: string): AttachmentInfo | undefined;
77
+ /**
78
+ * @param params - Attachment information and content to stage as a new attachment.
79
+ * @returns The staged attachment metadata.
80
+ * @internal
81
+ */
82
+ stageAddAttachment(params: {
83
+ data: Blob | File | string;
84
+ name: string;
85
+ contentType?: string;
86
+ globalId?: string;
87
+ }): AttachmentInfo;
88
+ /**
89
+ * @param files - Files to stage for addition.
90
+ * @param arcadeContextInfo - Context information used for filename expression evaluation.
91
+ * @returns The attachments staged for addition.
92
+ * @internal
93
+ */
94
+ stageAddAttachments(files: (Blob | File)[], arcadeContextInfo: ArcadeBatchFormCalculationContextInfo): Promise<AttachmentInfo[]>;
95
+ /**
96
+ * @param attachment - Attachment metadata to stage for deletion.
97
+ * @internal
98
+ */
99
+ stageDeleteAttachment(attachment: AttachmentInfo): void;
100
+ /**
101
+ * @param attachment - Attachment metadata to rename.
102
+ * @param name - New attachment name.
103
+ * @internal
104
+ */
105
+ stageRenameAttachment(attachment: AttachmentInfo, name: string): void;
106
+ /**
107
+ * @param attachment - Attachment metadata to replace.
108
+ * @param file - File contents for the replacement attachment.
109
+ * @param arcadeContextInfo - Context information used for filename expression evaluation.
110
+ * @internal
111
+ */
112
+ stageReplaceAttachment(attachment: AttachmentInfo, file: Blob | File, arcadeContextInfo: ArcadeBatchFormCalculationContextInfo): Promise<void>;
113
+ /** @internal */
114
+ toSubmitEdits(): PendingAttachmentEdits | null;
64
115
  }
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{property as e,subclass as n}from"../../../core/accessorSupport/decorators.js";import r from"./EditableInput.js";import a from"./SingleFeatureInputAdapter.js";let o=class extends r{constructor(t){super(t),this.attachments=[],this.group=null,this.single=new a({input:this}),this.type="attachment"}get allowUserRename(){return this.template.allowUserRename}get attachmentKeyword(){return this.template.attachmentKeyword?.trim()}get displayFilename(){return this.template.displayFilename}get feature(){return this.single.feature}get input(){return this.template.input}get layer(){return this.single.layer}get maxAttachmentCount(){return this.template.maxAttachmentCount}get minAttachmentCount(){return this.template.minAttachmentCount}get useOriginalFilename(){return this.template.useOriginalFilename}};t([e()],o.prototype,"allowUserRename",null),t([e()],o.prototype,"attachmentKeyword",null),t([e()],o.prototype,"attachments",void 0),t([e()],o.prototype,"displayFilename",null),t([e()],o.prototype,"feature",null),t([e()],o.prototype,"group",void 0),t([e()],o.prototype,"input",null),t([e()],o.prototype,"layer",null),t([e()],o.prototype,"maxAttachmentCount",null),t([e()],o.prototype,"minAttachmentCount",null),t([e({readOnly:!0})],o.prototype,"single",void 0),t([e({readOnly:!0})],o.prototype,"type",void 0),t([e()],o.prototype,"useOriginalFilename",null),o=t([n("esri.widgets.BatchAttributeForm.inputs.AttachmentElementInput")],o);const l=o;export{l as default};
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Collection.js";import a from"../../../core/Logger.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import s from"../../../core/ReactiveMap.js";import i from"../../../core/ReactiveSet.js";import{generateBracedUUID as o}from"../../../core/uuid.js";import{property as r,subclass as l}from"../../../core/accessorSupport/decorators.js";import d from"../../../rest/query/support/AttachmentInfo.js";import{isAttributeFormSupportedLayer as c}from"../batchAttributeFormUtils.js";import h from"./EditableInput.js";import m from"./SingleFeatureInputAdapter.js";let p=-1,u=class extends h{constructor(t){super(t),this.attachments=[],this.group=null,this.single=new m({input:this}),this.type="attachment",this._initialAttachments=[],this._stagedAdds=new e,this._stagedDeletes=new i,this._stagedUpdates=new s}get allowUserRename(){return this.template.allowUserRename}get attachmentKeyword(){return this.template.attachmentKeyword?.trim()}get displayFilename(){return this.template.displayFilename}get feature(){return this.single.feature}get hasAttachmentChanges(){return this._stagedAdds.length>0||this._stagedUpdates.size>0||this._stagedDeletes.size>0}get input(){return this.template.input}get layer(){return this.single.layer}get maxAttachmentCount(){return this.template.maxAttachmentCount}get minAttachmentCount(){return this.template.minAttachmentCount}get useOriginalFilename(){return this.template.useOriginalFilename}get valid(){const t=this.attachments.length,e=this.minAttachmentCount??-1/0,a=this.maxAttachmentCount??1/0,n=this.hasAttachmentChanges;return!(t<e||t>a)||!n}get _expressionLayer(){const t=this.layer;if(t)return"scene"===t.type&&"associatedLayer"in t&&null!=t.associatedLayer?t.associatedLayer:"feature"===t.type?t:void 0}applyFetchedAttachments(t){this._initialAttachments=t,this._recomputeAttachments()}clearAttachmentChanges(){this._stagedAdds.removeAll(),this._stagedUpdates.clear(),this._stagedDeletes.clear(),this._recomputeAttachments()}stageAddAttachment(t){const{contentType:e,data:a,name:n}=t,s=t.globalId??o(),i=new d({contentType:e??void 0,globalId:s,id:p--,keywords:this.attachmentKeyword??void 0,name:n});return this._stagedAdds.add({globalId:s,info:i,data:a}),this._recomputeAttachments(),i}async stageAddAttachments(t,e){if(0===t.length)return[];const a=[],n=new Map,s=Date.now();for(let i=0;i<t.length;i++){const o=t[i],r=o instanceof File?o.name:`attachment-${s}_${i+1}`,l=await this._computeAttachmentFilename(r,e),d=this._makeUniqueFilenameForOperation(n,l);a.push(this.stageAddAttachment({contentType:o.type,data:o,name:d}))}return a}findAttachment(t){if(t)return this.attachments.find(e=>e.globalId===t)}stageDeleteAttachment(t){const e=t.globalId;if(!e)return;const a=this._stagedAdds.findIndex(t=>t.globalId===e);if(a>-1)return this._stagedAdds.removeAt(a),void this._recomputeAttachments();this._stagedUpdates.delete(e),this._stagedDeletes.add(e),this._recomputeAttachments()}stageRenameAttachment(t,e){const a=t.globalId;if(!a)return;const n=this._stagedAdds.find(t=>t.globalId===a);if(n)return n.info.name=e,void this._recomputeAttachments();const s=this._stagedUpdates.get(a);this._stagedUpdates.set(a,{...s,info:t,name:e}),this._recomputeAttachments()}async stageReplaceAttachment(t,e,a){const n=e instanceof File?e.name:t.name,s=await this._computeAttachmentFilename(n,a);this._stageReplaceAttachment(t,e,s)}toSubmitEdits(){const t=[],e=[],n=Array.from(this._stagedDeletes);if(0===this._stagedAdds.length&&0===this._stagedUpdates.size&&0===n.length)return null;const s=this._featureIdentifier;if(!s)return a.getLogger(this).error("Unable to build attachment edits without a valid feature and layer."),null;for(const a of this._stagedAdds)t.push({feature:s,attachment:{globalId:a.globalId,contentType:a.info.contentType,data:a.data,name:a.info.name}});for(const[a,i]of this._stagedUpdates)e.push({feature:s,attachment:{globalId:a,contentType:i.contentType,data:i.data,name:i.name}});return{label:this.template.label,attachmentKeyword:this.attachmentKeyword,add:t,delete:n,update:e}}_recomputeAttachments(){const t=this._stagedDeletes,e=[];for(const a of this._stagedAdds)e.push(a.info);for(const a of this._initialAttachments){const n=a.globalId;if(!n||!t.has(n)){if(n&&this._stagedUpdates.has(n)){const t=this._stagedUpdates.get(n),s=a.clone();null!=t.name&&(s.name=t.name),e.push(s);continue}e.push(a)}}this.attachments=e}get _featureIdentifier(){const t=this.single.feature,e=this.layer;if(!t||!c(e))return null;const a=e.objectIdField,n="globalIdField"in e?e.globalIdField:null,s=t.getGlobalId()??(n?t.getAttribute(n):void 0);if(s)return{globalId:s};const i=t.getObjectId()??t.getAttribute(a),o=Number(i);return null==i||isNaN(o)?null:{objectId:o}}async _computeAttachmentFilename(t,e){const s=this.template.filenameExpressionExecutor;if(!s)return t;const i=this.single.feature,o=i?.plainGraphic,r=this._expressionLayer,l={$originalfeature:i?.original,$editcontext:{editType:e.editType},$layer:r,$featureset:r,$datastore:r?.url,$feature:o,$map:e.map},d={rawOutput:!0,spatialReference:e.spatialReference,timeZone:e.timeZone};try{const t=s.isAsync?await s.executeAsync(l,d):s.execute(l,d);if("string"==typeof t&&t.trim().length>0)return t.trim()}catch(c){n(c)||a.getLogger(this).error("Failed evaluating attachment filename expression",c)}return t}_makeUniqueFilenameForOperation(t,e){const a=e.toLowerCase(),n=t.get(a)??0;if(t.set(a,n+1),0===n)return e;const s=e.lastIndexOf(".");return`${s>0?e.slice(0,s):e}_${n}${s>0?e.slice(s):""}`}_stageReplaceAttachment(t,e,a){const n=t.globalId;if(!n)return;const s=this._stagedAdds.find(t=>t.globalId===n);if(s)return s.data=e,s.info.name=a,s.info.contentType=e.type,void this._recomputeAttachments();const i=this._stagedUpdates.get(n);this._stagedUpdates.set(n,{...i,info:t,contentType:e.type||i?.contentType,data:e,name:a}),this._recomputeAttachments()}};t([r()],u.prototype,"allowUserRename",null),t([r()],u.prototype,"attachmentKeyword",null),t([r()],u.prototype,"attachments",void 0),t([r()],u.prototype,"displayFilename",null),t([r()],u.prototype,"feature",null),t([r()],u.prototype,"group",void 0),t([r({readOnly:!0})],u.prototype,"hasAttachmentChanges",null),t([r()],u.prototype,"input",null),t([r()],u.prototype,"layer",null),t([r()],u.prototype,"maxAttachmentCount",null),t([r()],u.prototype,"minAttachmentCount",null),t([r({readOnly:!0})],u.prototype,"single",void 0),t([r({readOnly:!0})],u.prototype,"type",void 0),t([r()],u.prototype,"useOriginalFilename",null),t([r({readOnly:!0})],u.prototype,"valid",null),t([r()],u.prototype,"_initialAttachments",void 0),t([r()],u.prototype,"_expressionLayer",null),t([r()],u.prototype,"_stagedAdds",void 0),t([r()],u.prototype,"_stagedDeletes",void 0),t([r()],u.prototype,"_stagedUpdates",void 0),t([r()],u.prototype,"_featureIdentifier",null),u=t([l("esri.widgets.BatchAttributeForm.inputs.AttachmentElementInput")],u);const g=u;export{g as default};
@@ -1,6 +1,7 @@
1
1
  import type Graphic from "../../../Graphic.js";
2
2
  import type Accessor from "../../../core/Accessor.js";
3
3
  import type AttachmentElementInput from "./AttachmentElementInput.js";
4
+ import type EditableInput from "./EditableInput.js";
4
5
  import type FieldInput from "./FieldInput.js";
5
6
  import type { FormInput } from "./types.js";
6
7
 
@@ -15,6 +16,8 @@ export default class BatchFormInputs extends Accessor {
15
16
  constructor(properties?: BatchFormInputsProperties);
16
17
  /** Returns an array of all the attachment element inputs in the form, including those in groups. */
17
18
  get allAttachmentElementInputs(): AttachmentElementInput[];
19
+ /** Returns an array of all editable inputs in the form, including those in groups. */
20
+ get allEditableInputs(): EditableInput[];
18
21
  /** Returns an array of all the field inputs in the form, including those in groups. */
19
22
  get allFieldInputs(): FieldInput[];
20
23
  /** The description for the form. */
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{property as l,subclass as i}from"../../../core/accessorSupport/decorators.js";import{isFieldInput as n,isGroupInput as s,isAttachmentElementInput as r}from"./support/inputUtils.js";let p=class extends e{constructor(t){super(t),this.inputs=[],this.template=null}get allFieldInputs(){const t=[];for(const e of this.inputs)n(e)?t.push(e):s(e)&&t.push(...e.inputs.filter(n));return t}get allAttachmentElementInputs(){const t=[];for(const e of this.inputs)r(e)?t.push(e):s(e)&&t.push(...e.inputs.filter(r));return t}get description(){return this.template?.description??null}get hasInvalidHiddenInputs(){return this.invalidHiddenInputs.length>0}get invalidFeatures(){return Array.from(new Set(this.allFieldInputs.flatMap(t=>t.invalidFeatures)))}get invalidHiddenInputs(){return this.allFieldInputs.filter(t=>!t.valid&&!t.effectiveVisible)}get title(){return this.template?.title??null}get valid(){return this.allFieldInputs.every(t=>t.valid)}};t([l()],p.prototype,"allFieldInputs",null),t([l()],p.prototype,"allAttachmentElementInputs",null),t([l()],p.prototype,"description",null),t([l()],p.prototype,"inputs",void 0),t([l()],p.prototype,"hasInvalidHiddenInputs",null),t([l()],p.prototype,"invalidFeatures",null),t([l()],p.prototype,"invalidHiddenInputs",null),t([l()],p.prototype,"template",void 0),t([l()],p.prototype,"title",null),t([l()],p.prototype,"valid",null),p=t([i("esri.widgets.BatchAttributeForm.inputs.BatchFormInputs")],p);const o=p;export{o as default};
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{property as l,subclass as i}from"../../../core/accessorSupport/decorators.js";import{isFieldInput as n,isGroupInput as s,isAttachmentElementInput as p,isEditableInput as r}from"./support/inputUtils.js";let o=class extends e{constructor(t){super(t),this.inputs=[],this.template=null}get allFieldInputs(){const t=[];for(const e of this.inputs)n(e)?t.push(e):s(e)&&t.push(...e.inputs.filter(n));return t}get allAttachmentElementInputs(){const t=[];for(const e of this.inputs)p(e)?t.push(e):s(e)&&t.push(...e.inputs.filter(p));return t}get allEditableInputs(){const t=[];for(const e of this.inputs)if(r(e))t.push(e);else if(s(e))for(const l of e.inputs)r(l)&&t.push(l);return t}get description(){return this.template?.description??null}get hasInvalidHiddenInputs(){return this.invalidHiddenInputs.length>0}get invalidFeatures(){return Array.from(new Set(this.allFieldInputs.flatMap(t=>t.invalidFeatures)))}get invalidHiddenInputs(){return this.allFieldInputs.filter(t=>!t.valid&&!t.effectiveVisible)}get title(){return this.template?.title??null}get valid(){return this.allEditableInputs.every(t=>t.valid)}};t([l()],o.prototype,"allFieldInputs",null),t([l()],o.prototype,"allAttachmentElementInputs",null),t([l()],o.prototype,"allEditableInputs",null),t([l()],o.prototype,"description",null),t([l()],o.prototype,"inputs",void 0),t([l()],o.prototype,"hasInvalidHiddenInputs",null),t([l()],o.prototype,"invalidFeatures",null),t([l()],o.prototype,"invalidHiddenInputs",null),t([l()],o.prototype,"template",void 0),t([l()],o.prototype,"title",null),t([l()],o.prototype,"valid",null),o=t([i("esri.widgets.BatchAttributeForm.inputs.BatchFormInputs")],o);const u=o;export{u as default};
@@ -39,4 +39,6 @@ export default abstract class EditableInput<Template extends any = any> extends
39
39
  * @default "NA"
40
40
  */
41
41
  get editType(): EditType;
42
+ /** Indicates whether the input currently has valid user input. */
43
+ get valid(): boolean;
42
44
  }
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{property as e,subclass as s}from"../../../core/accessorSupport/decorators.js";import o from"./InputBase.js";let r=class extends o{constructor(){super(...arguments),this.editType="NA"}get editable(){return this._evaluatedEditableExpression??!0}get _evaluatedEditableExpression(){let t=!0,e=!0;for(const s of this.features){if(null==this.template.getExpressionExecutorsForLayer(s.layer)?.editableExpression){t=t&&!0;continue}e=!1;const o=this._lookupEvaluatedExpression(s,"editable");"success"===o?.status?t=t&&!0===o.result:t=!1}return e?null:t}};t([e()],r.prototype,"editable",null),t([e()],r.prototype,"editType",void 0),t([e()],r.prototype,"_evaluatedEditableExpression",null),r=t([s("esri.widgets.BatchAttributeForm.inputs.EditableInput")],r);const i=r;export{i as default};
2
+ import{__decorate as t}from"tslib";import{property as e,subclass as s}from"../../../core/accessorSupport/decorators.js";import r from"./InputBase.js";let o=class extends r{constructor(){super(...arguments),this.editType="NA"}get editable(){return this._evaluatedEditableExpression??!0}get valid(){return!0}get _evaluatedEditableExpression(){let t=!0,e=!0;for(const s of this.features){if(null==this.template.getExpressionExecutorsForLayer(s.layer)?.editableExpression){t=t&&!0;continue}e=!1;const r=this._lookupEvaluatedExpression(s,"editable");"success"===r?.status?t=t&&!0===r.result:t=!1}return e?null:t}};t([e()],o.prototype,"editable",null),t([e({readOnly:!0})],o.prototype,"valid",null),t([e()],o.prototype,"editType",void 0),t([e()],o.prototype,"_evaluatedEditableExpression",null),o=t([s("esri.widgets.BatchAttributeForm.inputs.EditableInput")],o);const i=o;export{i as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- const t="esri_BatchAttributeForm_different_values";function n(t){return"visible"===t}function e(t){return"field"===t.type}function r(t){return"group"===t.type}function o(t){return"relationship"===t.type}function u(t){return"text"===t.type}function i(t){return"attachment"===t.type}function c(t){return"utilityNetworkAssociations"===t.type}function s(t){const n=`${t.elementId}:${t.executorPurpose}`;return null!=t.textExpressionIndex?`${n}:${t.textExpressionIndex}`:n}const p=t=>null!=t&&(f(t,"combo-box")||f(t,"radio-buttons"));function f(t,n){return t?.type===n}export{t as differentValuesString,i as isAttachmentElementInput,e as isFieldInput,p as isFieldInputWithShowNoValueOptionInput,r as isGroupInput,f as isInputWithInputType,o as isRelationshipElementInput,u as isTextElementInput,c as isUtilityNetworkAssociationsElementInput,s as makeUseId,n as visibilityCodeToBoolean};
2
+ const t="esri_BatchAttributeForm_different_values";function n(t){return"visible"===t}function e(t){return"field"===t.type}function r(t){return"group"===t.type}function o(t){return"relationship"===t.type}function u(t){return"text"===t.type}function i(t){return"attachment"===t.type}function c(t){return e(t)||i(t)||o(t)||s(t)}function s(t){return"utilityNetworkAssociations"===t.type}function f(t){const n=`${t.elementId}:${t.executorPurpose}`;return null!=t.textExpressionIndex?`${n}:${t.textExpressionIndex}`:n}const p=t=>null!=t&&(l(t,"combo-box")||l(t,"radio-buttons"));function l(t,n){return t?.type===n}export{t as differentValuesString,i as isAttachmentElementInput,c as isEditableInput,e as isFieldInput,p as isFieldInputWithShowNoValueOptionInput,r as isGroupInput,l as isInputWithInputType,o as isRelationshipElementInput,u as isTextElementInput,s as isUtilityNetworkAssociationsElementInput,f as makeUseId,n as visibilityCodeToBoolean};
@@ -6,6 +6,7 @@ import type OrientedImageryLayer from "../../layers/OrientedImageryLayer.js";
6
6
  import type SceneLayer from "../../layers/SceneLayer.js";
7
7
  import type KnowledgeGraphSublayer from "../../layers/knowledgeGraph/KnowledgeGraphSublayer.js";
8
8
  import type SubtypeSublayer from "../../layers/support/SubtypeSublayer.js";
9
+ import type { AttachmentEdit } from "../../editing/types.js";
9
10
  import type { FieldValue } from "../../layers/support/fieldUtils.js";
10
11
 
11
12
  /**
@@ -53,6 +54,56 @@ export interface SubmitResult {
53
54
  * @since 5.0
54
55
  */
55
56
  values: Graphic["attributes"];
57
+ /**
58
+ * Staged attachment edits for this feature.
59
+ *
60
+ * @since 5.1
61
+ */
62
+ attachmentEdits?: PendingAttachmentEdits[];
63
+ /**
64
+ * The element ids of attachment elements that are currently invalid.
65
+ *
66
+ * @since 5.1
67
+ */
68
+ invalidAttachmentElementIds?: string[];
69
+ }
70
+
71
+ /**
72
+ * Attachment edits staged for a single attachment element.
73
+ *
74
+ * @since 5.1
75
+ */
76
+ export interface PendingAttachmentEdits {
77
+ /**
78
+ * The display label of the attachment element input.
79
+ *
80
+ * @since 5.1
81
+ */
82
+ label?: string | null;
83
+ /**
84
+ * The keyword configured on the attachment element input.
85
+ *
86
+ * @since 5.1
87
+ */
88
+ attachmentKeyword?: string | null;
89
+ /**
90
+ * Attachments staged to be added.
91
+ *
92
+ * @since 5.1
93
+ */
94
+ add: AttachmentEdit[];
95
+ /**
96
+ * Attachments staged to be updated.
97
+ *
98
+ * @since 5.1
99
+ */
100
+ update: AttachmentEdit[];
101
+ /**
102
+ * Attachment globalIds staged to be deleted.
103
+ *
104
+ * @since 5.1
105
+ */
106
+ delete: string[];
56
107
  }
57
108
 
58
109
  /** @since 5.0 */
@@ -77,6 +128,34 @@ export interface SubmitEvent {
77
128
  valid: boolean;
78
129
  }
79
130
 
131
+ /** @since 5.1 */
132
+ export interface AttachmentsChangeEvent {
133
+ /**
134
+ * The name of the event.
135
+ *
136
+ * @since 5.1
137
+ */
138
+ name: "attachments-change";
139
+ /**
140
+ * The feature whose attachment edits were updated.
141
+ *
142
+ * @since 5.1
143
+ */
144
+ feature: Graphic;
145
+ /**
146
+ * The current attachment edits for the updated feature.
147
+ *
148
+ * @since 5.1
149
+ */
150
+ attachmentEdits: PendingAttachmentEdits[];
151
+ /**
152
+ * Indicates whether the form is valid.
153
+ *
154
+ * @since 5.1
155
+ */
156
+ valid: boolean;
157
+ }
158
+
80
159
  /** @since 5.0 */
81
160
  export interface ValueChangeEvent {
82
161
  /**
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import{debounce as i,ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{property as r,subclass as o}from"../../core/accessorSupport/decorators.js";import{attributesAreEquivalent as a}from"./support/editsUtils.js";function l(t){return null==t?null:JSON.stringify(t)}let n=class extends e{constructor(t){super(t),this._stagedForDelete=!1,this.feature=null,this.initialFeature=null,this.submittable=!1,this.displayTitle=null,this.isAssociation=!1,this._debouncedRefreshDisplayTitle=i(this._refreshDisplayTitle.bind(this),100)}get attributesModified(){return!a(this.initialFeature?.attributes,this.feature?.attributes)}get geometryModified(){return this._stringifyGeometry(this.feature)!==this._stringifyGeometry(this.initialFeature)}get stagedForDelete(){return this._stagedForDelete}get modified(){return this.attributesModified||this.geometryModified||this._stagedForDelete}set timeZone(t){this._set("timeZone",t),s(this._debouncedRefreshDisplayTitle())}setAttribute(t,e){const{feature:i}=this;i&&(i.setAttribute(t,e),this.notifyChange("attributesModified")),s(this._debouncedRefreshDisplayTitle())}stageDelete(){this._stagedForDelete=!0}unstageDelete(){this._stagedForDelete=!1}trackChanges(t=this.feature){this.initialFeature=t?.clone(),s(this._debouncedRefreshDisplayTitle())}updateAttributes(t){const{feature:e}=this;e&&(e.attributes=t,this.notifyChange("attributesModified")),s(this._debouncedRefreshDisplayTitle())}updateGeometry(t){const{feature:e}=this;e&&(e.geometry=t,this.notifyChange("geometryModified"))}_stringifyGeometry(t){const e=t?.geometry;return l("mesh"===e?.type?{transform:e.transform??null,vertexSpace:e.vertexSpace}:e)}async _refreshDisplayTitle(t){const e=this.feature,i=e?.sourceLayer;if(!i||!("getFeatureTitle"in i))return;const s=await i.getFeatureTitle(e,{fetchMissingFields:!1,removeHTML:!0,timeZone:this.timeZone});t.aborted||(this.displayTitle=""===s?null:s)}};t([r()],n.prototype,"_stagedForDelete",void 0),t([r()],n.prototype,"attributesModified",null),t([r()],n.prototype,"feature",void 0),t([r()],n.prototype,"geometryModified",null),t([r()],n.prototype,"initialFeature",void 0),t([r()],n.prototype,"modified",null),t([r()],n.prototype,"submittable",void 0),t([r()],n.prototype,"displayTitle",void 0),t([r()],n.prototype,"isAssociation",void 0),t([r()],n.prototype,"timeZone",null),n=t([o("esri.widgets.Editor.Edits")],n);const u=n;export{u as default};
2
+ import{__decorate as t}from"tslib";import e from"../../core/Accessor.js";import i from"../../core/Collection.js";import{debounce as s,ignoreAbortErrors as r}from"../../core/promiseUtils.js";import{property as o,subclass as a}from"../../core/accessorSupport/decorators.js";import{attributesAreEquivalent as n}from"./support/editsUtils.js";function d(t){return null==t?null:JSON.stringify(t)}let l=class extends e{constructor(t){super(t),this._stagedForDelete=!1,this._attachmentEdits=new i,this.feature=null,this.initialFeature=null,this.submittable=!1,this.displayTitle=null,this.isAssociation=!1,this._debouncedRefreshDisplayTitle=s(this._refreshDisplayTitle.bind(this),100)}get attributesModified(){return!n(this.initialFeature?.attributes,this.feature?.attributes)}get geometryModified(){return this._stringifyGeometry(this.feature)!==this._stringifyGeometry(this.initialFeature)}get stagedForDelete(){return this._stagedForDelete}get modified(){return this.attributesModified||this.geometryModified||this.attachmentsModified||this._stagedForDelete}get attachmentsModified(){return this._attachmentEdits.some(t=>t.add.length>0||t.update.length>0||t.delete.length>0)}get attachmentEdits(){return this._attachmentEdits.toArray()}set timeZone(t){this._set("timeZone",t),r(this._debouncedRefreshDisplayTitle())}setAttribute(t,e){const{feature:i}=this;i&&(i.setAttribute(t,e),this.notifyChange("attributesModified")),r(this._debouncedRefreshDisplayTitle())}setAttachmentEdits(t){this._attachmentEdits.removeAll(),t?.length&&this._attachmentEdits.addMany(t)}stageDelete(){this._stagedForDelete=!0}unstageDelete(){this._stagedForDelete=!1}trackChanges(t=this.feature){this.initialFeature=t?.clone(),this._attachmentEdits.removeAll(),r(this._debouncedRefreshDisplayTitle())}updateAttributes(t){const{feature:e}=this;e&&(e.attributes=t,this.notifyChange("attributesModified")),r(this._debouncedRefreshDisplayTitle())}updateGeometry(t){const{feature:e}=this;e&&(e.geometry=t,this.notifyChange("geometryModified"))}_stringifyGeometry(t){const e=t?.geometry;return d("mesh"===e?.type?{transform:e.transform??null,vertexSpace:e.vertexSpace}:e)}async _refreshDisplayTitle(t){const e=this.feature,i=e?.sourceLayer;if(!i||!("getFeatureTitle"in i))return;const s=await i.getFeatureTitle(e,{fetchMissingFields:!1,removeHTML:!0,timeZone:this.timeZone});t.aborted||(this.displayTitle=""===s?null:s)}};t([o()],l.prototype,"_stagedForDelete",void 0),t([o()],l.prototype,"_attachmentEdits",void 0),t([o()],l.prototype,"attributesModified",null),t([o()],l.prototype,"feature",void 0),t([o()],l.prototype,"geometryModified",null),t([o()],l.prototype,"initialFeature",void 0),t([o()],l.prototype,"modified",null),t([o()],l.prototype,"attachmentsModified",null),t([o({readOnly:!0})],l.prototype,"attachmentEdits",null),t([o()],l.prototype,"submittable",void 0),t([o()],l.prototype,"displayTitle",void 0),t([o()],l.prototype,"isAssociation",void 0),t([o()],l.prototype,"timeZone",null),l=t([a("esri.widgets.Editor.Edits")],l);const h=l;export{h as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import r from"../../core/Error.js";import o from"../../core/Logger.js";import{destroyMaybe as i}from"../../core/maybe.js";import{whenOnce as s}from"../../core/reactiveUtils.js";import{property as a,subclass as n}from"../../core/accessorSupport/decorators.js";import{isSceneLayer as l,isTable as u}from"../../layers/support/layerUtils.js";import d from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import p from"./UpdateFeaturesWorkflowData.js";import c from"./Workflow.js";import{whenEditorLayerView as f,findEditorItemForLayer as h}from"./workflowUtils.js";import{MultipleSourceLayersError as m}from"./support/errors.js";import{SketchController as g}from"./support/SketchController.js";var y;const w=()=>o.getLogger("esri.widgets.Editor.UpdateFeaturesWorkflow"),F=Symbol();let v=y=class extends c{constructor(e){super(e),this.type="update-features",this._formViewModel=null,this._sketchController=null}async initialize(){this._initializeFormViewModel();try{await this._updatingHandles.addPromise((async()=>{const{fullFeatures:e}=await this.data.when();this._formViewModel.features=new t(e),this._initializeVisuals(e)})())}catch(e){this.cancel({force:!0,error:new r("update-features-workflow:initialize","Failed to initialize the workflow data.",e)})}}destroy(){this._sketchController=i(this._sketchController),this._formViewModel.destroy()}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get features(){return this.data.features}get featureInfos(){return this.data.featureInfos}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return this.data.editorItems.some(e=>e.hasInvalidFormTemplate)}get hasPendingEdits(){const{data:e}=this;return e.fullFeatures.some(t=>!!e.getPendingEditsForFeature(t)?.modified)}get parent(){return this.data.parent}get saveActionLabel(){return"update"}get selectedFeature(){return this.data.selectedFeature}get sketchUpdateOptions(){const{data:e}=this,t=e.fullFeatures,r=M(e),o=e.getEditorItemForLayer(r),i=!this.selectedFeature||t.length>1;return{multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!l(r)&&!!o?.capabilities.supportsTrueCurve},tool:i?"move":void 0}}get sketchViewModel(){return this._sketchController?.viewModel}get supportsMergeFeaturesWorkflow(){const e=this.data,{fullFeatures:t,layers:r}=e;return!(1!==r.length||t.length<2)&&(!this.curveUpdatesDisabled&&!!e.getEditorItemForLayer(r[0])?.supportsMergeFeaturesWorkflow)}getUpdating(){return!!this._sketchController?.updating}get viewGraphics(){return this._sketchController?.sketchGraphics??this.data.fullFeatures}async commit(){const{data:e,_formViewModel:t}=this;for(const r of e.fullFeatures)E(e.getPendingEditsForFeature(r),t.getValues(r));await super.commit()}static create(e){const{applyEdits:t,applyEditsFeatureService:r,...o}=e,{features:i,featureInfos:s,viewModel:a}=o,n=new Set;function l(e){const t=h(a.editorItems,e);t&&n.add(t)}s?.length?s.forEach(({layer:e})=>l(e)):i?.length&&(w().warn("editor:update-features-workflow-data-features","UpdateFeaturesWorkflow: 'features' is deprecrated, use 'featureInfos'"),i.forEach(e=>l(e.sourceLayer??e.layer)));const u=Array.from(n),d=new y({data:new p({...o,editorItems:u}),onCommit:_(e.applyEdits)});return d._set("steps",k()),d}async deleteAndCommit(){return this.data.stageDelete(),this.commit()}async enter(){}exit(e){}async reset(){}async save(){const{formViewModel:e}=this;e.submit(),e.valid&&await super.save()}async start(){await super.start(),await s(()=>!this.updating);const e=this._sketchController;if(e)return e;const{data:t}=this,{view:r}=t.viewModel,o=M(t);return!r||u(o)?{enter:async()=>{},exit:()=>{}}:{enter:()=>this._initializeHighlights(t.fullFeatures,o,r),exit:()=>this.removeHandles(F)}}_initializeFormViewModel(){const{data:e}=this,t=e.viewModel.view,r=e.getEditorItemForLayer(M(e)),o=r?.layerInfo?[r.layerInfo]:null,i=new d({editType:"UPDATE",map:t?.map,readOnly:!1===r?.capabilities.update.attributes,spatialReference:t?.spatialReference,timeZone:e.timeZone,layerInfos:o});this._formViewModel=i,this.addHandles(i.on("value-change",t=>{for(const r of t.features)e.getPendingEditsForFeature(r)?.setAttribute(t.fieldName,t.value);this._sketchController?.notifyAttributesChanged(t)}))}async _initializeHighlights(e,t,r){const o=await f(r,t);this.addHandles(o.highlight(e),F)}_initializeSketchController(e,t,r){const{data:o}=this,i=new g({defaultUpdateOptions:this.sketchUpdateOptions,sourceLayer:t,view:r,features:e,useLegacyCreateTools:o.viewModel.useLegacyCreateTools,onGeometriesUpdated:e=>{const t=[];for(const{feature:r,geometry:i}of e)o.getPendingEditsForFeature(r)?.updateGeometry(i),t.push(r);this._formViewModel.notifyGeometriesChanged(t)},onVisualVariableAttributesUpdated:()=>{w().warnOnce("editor:batch-update-visual-variables","UpdateFeaturesWorkflow does not currently support modifying visual variables through the scale and rotate tools.")}});this._sketchController=i}_initializeVisuals(e){const{data:t}=this,{view:r}=t.viewModel;if(!r)return;const o=M(t);if(u(o))return;const i=t.getEditorItemForLayer(o);i?.capabilities.update.geometry&&!this.curveUpdatesDisabled&&this._initializeSketchController(e,o,r)}};e([a()],v.prototype,"curveUpdatesDisabled",null),e([a()],v.prototype,"features",null),e([a()],v.prototype,"featureInfos",null),e([a()],v.prototype,"formViewModel",null),e([a()],v.prototype,"hasInvalidFormTemplate",null),e([a()],v.prototype,"hasPendingEdits",null),e([a()],v.prototype,"parent",null),e([a()],v.prototype,"saveActionLabel",null),e([a()],v.prototype,"selectedFeature",null),e([a()],v.prototype,"sketchUpdateOptions",null),e([a()],v.prototype,"sketchViewModel",null),e([a()],v.prototype,"supportsMergeFeaturesWorkflow",null),e([a()],v.prototype,"type",void 0),e([a()],v.prototype,"viewGraphics",null),e([a()],v.prototype,"_formViewModel",void 0),e([a()],v.prototype,"_sketchController",void 0),v=y=e([n("esri.widgets.Editor.UpdateFeaturesWorkflow")],v);const b=v;function k(){return[{id:"editing-features",async setUp(){},async tearDown(){}}]}function _(e){return async t=>{const r=M(t),o=[],i=[];for(const e of t.fullFeatures){const r=t.getPendingEditsForFeature(e),s=r?.stagedForDelete;if(!r?.modified&&!s)continue;const a=e.clone();if(!r?.attributesModified||s){const t=e.sourceLayer;if(!t){w().warn("Feature has no sourceLayer. It will not be included in any applyEdits payload.");continue}const r=t.objectIdField;if(a.attributes={[r]:e.getAttribute(r)},"scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&a.setAttribute(r,e.getAttribute(r))}}r?.geometryModified&&!s||(a.geometry=null),s?i.push(a):o.push(a)}if(o.length+i.length===0)return void w().warn("No edits to apply. Workflow will finish without sending an applyEdits request.");const s={updateFeatures:o.length>0?o:void 0,deleteFeatures:i.length>0?i:void 0};await e(r,s)}}function M(e){if(e.layers.length>1)throw new m;return e.layers[0]}function E(e,t){if(!e||!e.feature)return;const{attributes:r}=e.feature;Object.keys(t).some(e=>t[e]!==r[e])&&e.updateAttributes(t)}export{b as default};
2
+ import{__decorate as e}from"tslib";import{addMany as t}from"../../core/arrayUtils.js";import r from"../../core/Collection.js";import o from"../../core/Error.js";import i from"../../core/Logger.js";import{destroyMaybe as s}from"../../core/maybe.js";import{whenOnce as a}from"../../core/reactiveUtils.js";import{property as n,subclass as l}from"../../core/accessorSupport/decorators.js";import{isSceneLayer as d,isTable as u}from"../../layers/support/layerUtils.js";import c from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import p from"./UpdateFeaturesWorkflowData.js";import h from"./Workflow.js";import{whenEditorLayerView as f,findEditorItemForLayer as m}from"./workflowUtils.js";import{MultipleSourceLayersError as g}from"./support/errors.js";import{SketchController as y}from"./support/SketchController.js";var w;const F=()=>i.getLogger("esri.widgets.Editor.UpdateFeaturesWorkflow"),v=Symbol();let b=w=class extends h{constructor(e){super(e),this.type="update-features",this._formViewModel=null,this._sketchController=null}async initialize(){this._initializeFormViewModel();try{await this._updatingHandles.addPromise((async()=>{const{fullFeatures:e}=await this.data.when();this._formViewModel.features=new r(e),this._initializeVisuals(e)})())}catch(e){this.cancel({force:!0,error:new o("update-features-workflow:initialize","Failed to initialize the workflow data.",e)})}}destroy(){this._sketchController=s(this._sketchController),this._formViewModel.destroy()}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get features(){return this.data.features}get featureInfos(){return this.data.featureInfos}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return this.data.editorItems.some(e=>e.hasInvalidFormTemplate)}get hasPendingEdits(){const{data:e}=this;return e.fullFeatures.some(t=>!!e.getPendingEditsForFeature(t)?.modified)}get parent(){return this.data.parent}get saveActionLabel(){return"update"}get selectedFeature(){return this.data.selectedFeature}get sketchUpdateOptions(){const{data:e}=this,t=e.fullFeatures,r=_(e),o=e.getEditorItemForLayer(r),i=!this.selectedFeature||t.length>1;return{multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!d(r)&&!!o?.capabilities.supportsTrueCurve},tool:i?"move":void 0}}get sketchViewModel(){return this._sketchController?.viewModel}get supportsMergeFeaturesWorkflow(){const e=this.data,{fullFeatures:t,layers:r}=e;return!(1!==r.length||t.length<2)&&(!this.curveUpdatesDisabled&&!!e.getEditorItemForLayer(r[0])?.supportsMergeFeaturesWorkflow)}getUpdating(){return!!this._sketchController?.updating}get viewGraphics(){return this._sketchController?.sketchGraphics??this.data.fullFeatures}async commit(){const{data:e,_formViewModel:t}=this;for(const r of e.fullFeatures)U(e.getPendingEditsForFeature(r),t.getValues(r));await super.commit()}static create(e){const{applyEdits:t,applyEditsFeatureService:r,...o}=e,{features:i,featureInfos:s,viewModel:a}=o,n=new Set;function l(e){const t=m(a.editorItems,e);t&&n.add(t)}s?.length?s.forEach(({layer:e})=>l(e)):i?.length&&(F().warn("editor:update-features-workflow-data-features","UpdateFeaturesWorkflow: 'features' is deprecrated, use 'featureInfos'"),i.forEach(e=>l(e.sourceLayer??e.layer)));const d=Array.from(n),u=new w({data:new p({...o,editorItems:d}),onCommit:M(e.applyEdits)});return u._set("steps",E()),u}async deleteAndCommit(){return this.data.stageDelete(),this.commit()}async enter(){}exit(e){}async reset(){}async save(){const{formViewModel:e}=this;e.submit(),e.valid&&await super.save()}async start(){await super.start(),await a(()=>!this.updating);const e=this._sketchController;if(e)return e;const{data:t}=this,{view:r}=t.viewModel,o=_(t);return!r||u(o)?{enter:async()=>{},exit:()=>{}}:{enter:()=>this._initializeHighlights(t.fullFeatures,o,r),exit:()=>this.removeHandles(v)}}_initializeFormViewModel(){const{data:e}=this,t=e.viewModel.view,r=e.getEditorItemForLayer(_(e)),o=r?.layerInfo?[r.layerInfo]:null,i=new c({editType:"UPDATE",map:t?.map,readOnly:!1===r?.capabilities.update.attributes,spatialReference:t?.spatialReference,timeZone:e.timeZone,layerInfos:o});this._formViewModel=i,this.addHandles(i.on("value-change",t=>{for(const r of t.features)e.getPendingEditsForFeature(r)?.setAttribute(t.fieldName,t.value);this._sketchController?.notifyAttributesChanged(t)}));const s=t=>{e.getPendingEditsForFeature(t.feature)?.setAttachmentEdits(t.attachmentEdits)};this.addHandles(i.on("attachments-change",s))}async _initializeHighlights(e,t,r){const o=await f(r,t);this.addHandles(o.highlight(e),v)}_initializeSketchController(e,t,r){const{data:o}=this,i=new y({defaultUpdateOptions:this.sketchUpdateOptions,sourceLayer:t,view:r,features:e,useLegacyCreateTools:o.viewModel.useLegacyCreateTools,onGeometriesUpdated:e=>{const t=[];for(const{feature:r,geometry:i}of e)o.getPendingEditsForFeature(r)?.updateGeometry(i),t.push(r);this._formViewModel.notifyGeometriesChanged(t)},onVisualVariableAttributesUpdated:()=>{F().warnOnce("editor:batch-update-visual-variables","UpdateFeaturesWorkflow does not currently support modifying visual variables through the scale and rotate tools.")}});this._sketchController=i}_initializeVisuals(e){const{data:t}=this,{view:r}=t.viewModel;if(!r)return;const o=_(t);if(u(o))return;const i=t.getEditorItemForLayer(o);i?.capabilities.update.geometry&&!this.curveUpdatesDisabled&&this._initializeSketchController(e,o,r)}};e([n()],b.prototype,"curveUpdatesDisabled",null),e([n()],b.prototype,"features",null),e([n()],b.prototype,"featureInfos",null),e([n()],b.prototype,"formViewModel",null),e([n()],b.prototype,"hasInvalidFormTemplate",null),e([n()],b.prototype,"hasPendingEdits",null),e([n()],b.prototype,"parent",null),e([n()],b.prototype,"saveActionLabel",null),e([n()],b.prototype,"selectedFeature",null),e([n()],b.prototype,"sketchUpdateOptions",null),e([n()],b.prototype,"sketchViewModel",null),e([n()],b.prototype,"supportsMergeFeaturesWorkflow",null),e([n()],b.prototype,"type",void 0),e([n()],b.prototype,"viewGraphics",null),e([n()],b.prototype,"_formViewModel",void 0),e([n()],b.prototype,"_sketchController",void 0),b=w=e([l("esri.widgets.Editor.UpdateFeaturesWorkflow")],b);const k=b;function E(){return[{id:"editing-features",async setUp(){},async tearDown(){}}]}function M(e){return async r=>{const o=_(r),i=[],s=[],a=[],n=[],l=[];for(const e of r.fullFeatures){const o=r.getPendingEditsForFeature(e),d=o?.stagedForDelete;if(!o?.modified&&!d)continue;const u=e.clone();if(!o?.attributesModified||d){const t=e.sourceLayer;if(!t){F().warn("Feature has no sourceLayer. It will not be included in any applyEdits payload.");continue}const r=t.objectIdField;if(u.attributes={[r]:e.getAttribute(r)},"scene"===t.type&&null!=t.infoFor3D){const r=t.associatedLayer?.globalIdField;null!=r&&u.setAttribute(r,e.getAttribute(r))}}if(o?.geometryModified&&!d||(u.geometry=null),d?s.push(u):(o?.attributesModified||o?.geometryModified)&&i.push(u),o?.attachmentEdits)for(const e of o.attachmentEdits)t(a,e.add),t(n,e.update),t(l,e.delete)}if(i.length+s.length+a.length+n.length+l.length===0)return void F().warn("No edits to apply. Workflow will finish without sending an applyEdits request.");const d={updateFeatures:i.length>0?i:void 0,deleteFeatures:s.length>0?s:void 0,addAttachments:a.length>0?a:void 0,updateAttachments:n.length>0?n:void 0,deleteAttachments:l.length>0?l:void 0},u=o.capabilities?.editing.supportsGlobalId&&(a.length>0||n.length>0||l.length>0)?{globalIdUsed:!0}:void 0;await e(o,d,u)}}function _(e){if(e.layers.length>1)throw new g;return e.layers[0]}function U(e,t){if(!e||!e.feature)return;const{attributes:r}=e.feature;Object.keys(t).some(e=>t[e]!==r[e])&&e.updateAttributes(t)}export{k as default};