@arcgis/core 5.2.0-next.117 → 5.2.0-next.118

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 (190) hide show
  1. package/analysis/ElevationProfile/ElevationProfileLineQuery.d.ts +1 -1
  2. package/analysis/featureReferenceUtils.js +1 -1
  3. package/arcade.d.ts +1 -1
  4. package/arcade.js +1 -1
  5. package/assets/esri/core/workers/RemoteClient.js +1 -1
  6. package/assets/esri/core/workers/chunks/03918a862455191a8910.js +1 -0
  7. package/assets/esri/core/workers/chunks/{9b9a60f1e0c48aa701f0.js → 066b7f6866d602f963e0.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{4bfd63f3cf9208eb839b.js → 0dc317d022807af92e3f.js} +41 -41
  9. package/assets/esri/core/workers/chunks/{564fdf0d663b773806cc.js → 114bc14c49176f64a2c5.js} +1 -1
  10. package/assets/esri/core/workers/chunks/1630913399384030d0b9.js +1 -0
  11. package/assets/esri/core/workers/chunks/{db141122060d8d9b38da.js → 1742dbc6a827cfda471b.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{045ff98313b06a2188b7.js → 1a39335aa2dce6d564d9.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{caf38cf4d8542fb11c46.js → 20e4277a4a6c57957202.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{729d458e9e28641227cd.js → 21c0743b2f612e7e7de3.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{f42243c62dd0b6993816.js → 24014f3701c31ee74bc2.js} +1 -1
  16. package/assets/esri/core/workers/chunks/37cf4ca2083cd3b6002e.js +1 -0
  17. package/assets/esri/core/workers/chunks/{44d3fe10cb35d16f0b33.js → 4396ef5ab3eb9e9a7df2.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{3b499cfc89c8f87cdb20.js → 4925d0b29a166cc8fee1.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{56989b48c0a5d7fe85e6.js → 4c4ba466e23159991322.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{b9023cc3298ee4fddea7.js → 54f3bc940cea15fce2c7.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{7e42be27ead91a4cc0f1.js → 581285e4d7bbe1b7c27a.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{05584d8828ae7bca0fc5.js → 64ee22134fda2f09c094.js} +1 -1
  23. package/assets/esri/core/workers/chunks/6efc5873747b9cd44fb9.js +1 -0
  24. package/assets/esri/core/workers/chunks/{0463c807b37f01bbc35c.js → 70347d25968975126fa7.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{1eafb214519d8fc63ccb.js → 8465e2c7221125fd3cc4.js} +1 -1
  26. package/assets/esri/core/workers/chunks/862e1acd80c4e43831dc.js +1 -0
  27. package/assets/esri/core/workers/chunks/{fd808d38ae2d475ac442.js → 8675ab3c4dec2f13b9c6.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{925a0b29d3ed7165b8dd.js → 8984d02c0ce828fd223a.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{57328c206f1e699ac06f.js → 89edaa1ffa566908ebca.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{bb4cbf6b7c35e8c78cc7.js → a917a1df8270860dc514.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{996438b3afec92c5c68e.js → b0058619e0363002ad86.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{9fb46ccd4be4c3b61c31.js → b5a102cf9f4377fb9842.js} +1 -1
  33. package/assets/esri/core/workers/chunks/b6409d89914030d5854a.js +1 -0
  34. package/assets/esri/core/workers/chunks/{2e0fd0536408053ac6f5.js → b961e0aaa6b3ea75315c.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{fa869977ac2abb063925.js → b9c834e3c0701e9b14a2.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{32dd990a3bd93cbad309.js → c0ec87800faf99cbd8bd.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{20de0ea9fa08a6545978.js → cf1106eda10f3cccb1bd.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{ed988360264574cd8f6b.js → cf7c06702babd6fa88b4.js} +1 -1
  39. package/assets/esri/core/workers/chunks/cfd8317ecd2e63af7c40.js +1 -0
  40. package/assets/esri/core/workers/chunks/d090baaa974e1e83fa44.js +1 -0
  41. package/assets/esri/core/workers/chunks/{c5ceceb0683671f92efa.js → da6583e8d88441a1c02a.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{e1f2b07be33e33117313.js → dd02cc18ebebb90778c6.js} +1 -1
  43. package/assets/esri/core/workers/chunks/de8a3a0796bd115426c0.js +1 -0
  44. package/assets/esri/core/workers/chunks/{05b373a663cb5d4d722f.js → deb5b1d772ca407654d4.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{10fa8fbade8ae084c307.js → e22a013ec38989caf9de.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{c7e6b5594fed5bb16691.js → e4016ae9cb8f16e3efc3.js} +1 -1
  47. package/assets/esri/core/workers/chunks/e5f0c47957a4e9663720.js +1 -0
  48. package/assets/esri/core/workers/chunks/{a3f4818f4190fa92331d.js → edd36e98355f1655e5c8.js} +1 -1
  49. package/assets/esri/core/workers/chunks/ef6e52f9b656751eebaf.js +1 -0
  50. package/assets/esri/core/workers/chunks/f0709c48daca93e759c8.js +1 -0
  51. package/assets/esri/core/workers/chunks/f5423006fb07db7dd6ee.js +1 -0
  52. package/assets/esri/core/workers/chunks/{d926bffc3ff9f87e9081.js → f890359d972cce54459e.js} +1 -1
  53. package/assets/esri/core/workers/chunks/fb11ff3f2eae5f072560.js +1 -0
  54. package/assets/esri/core/workers/chunks/fdad31bbe8aee68a6eaf.js +1 -0
  55. package/assets/esri/core/workers/chunks/fe1787a8d499832996b3.js +1 -0
  56. package/chunks/CloudsComposition.glsl.js +2 -2
  57. package/chunks/ColorMaterial.glsl.js +3 -3
  58. package/chunks/Compositing.glsl.js +4 -4
  59. package/chunks/DeepSky.glsl.js +3 -3
  60. package/chunks/EdgeShader.glsl.js +6 -6
  61. package/chunks/FocusArea.glsl.js +1 -1
  62. package/chunks/GlobalIllumination.glsl.js +7 -7
  63. package/chunks/HUDMaterial.glsl.js +5 -5
  64. package/chunks/LaserlinePath.glsl.js +5 -5
  65. package/chunks/LineCallout.glsl.js +2 -2
  66. package/chunks/LineMarker.glsl.js +30 -30
  67. package/chunks/NavigationDepth.glsl.js +1 -1
  68. package/chunks/OccludedGeometryDepth.glsl.js +2 -2
  69. package/chunks/Path.glsl.js +12 -12
  70. package/chunks/PointRenderer.glsl.js +5 -5
  71. package/chunks/Precipitation.glsl.js +7 -7
  72. package/chunks/RibbonLine.glsl.js +50 -50
  73. package/chunks/SimpleAtmosphere.glsl.js +9 -9
  74. package/chunks/Stars.glsl.js +5 -5
  75. package/chunks/Terrain.glsl.js +18 -16
  76. package/chunks/Viewshed.glsl.js +3 -3
  77. package/chunks/VolumeMask.glsl.js +2 -2
  78. package/chunks/Water.glsl.js +20 -19
  79. package/config.js +1 -1
  80. package/core/NestedMap.js +1 -1
  81. package/kernel.js +1 -1
  82. package/layers/AnnotationFeatureLayer.d.ts +2 -1
  83. package/layers/AnnotationFeatureLayer.js +1 -1
  84. package/layers/CatalogLayer.d.ts +2 -1
  85. package/layers/CatalogLayer.js +1 -1
  86. package/layers/DimensionFeatureLayer.d.ts +2 -1
  87. package/layers/DimensionFeatureLayer.js +1 -1
  88. package/layers/FeatureLayer.d.ts +2 -30
  89. package/layers/FeatureLayer.js +1 -1
  90. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  91. package/layers/SubtypeGroupLayer.d.ts +2 -1
  92. package/layers/SubtypeGroupLayer.js +1 -1
  93. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  94. package/layers/mixins/FeatureLayerBase.js +1 -1
  95. package/layers/mixins/FeatureLayerReload.d.ts +26 -0
  96. package/layers/mixins/FeatureLayerReload.js +2 -0
  97. package/layers/mixins/PortalLayer.js +1 -1
  98. package/layers/support/TimeInfo.d.ts +2 -2
  99. package/layers/support/TimeInfo.js +1 -1
  100. package/layers/support/fieldUtils.js +1 -1
  101. package/package.json +2 -2
  102. package/support/revision.js +1 -1
  103. package/time/timeZoneUtils.js +1 -1
  104. package/views/3d/analysis/LineOfSight/LineOfSightEditTool.js +1 -1
  105. package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
  106. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  107. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  108. package/views/3d/support/engineContent/line.js +1 -1
  109. package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js +2 -2
  110. package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepthToWriteShadowMap.glsl.js +4 -4
  111. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +9 -9
  112. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +15 -15
  113. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +3 -3
  114. package/views/3d/webgl-engine/core/shaderLibrary/shading/MarkerSizing.glsl.js +23 -23
  115. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js +8 -8
  116. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +7 -7
  117. package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +7 -7
  118. package/views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js +1 -1
  119. package/views/3d/webgl-engine/core/shaderLibrary/util/cameraUniforms.js +2 -0
  120. package/views/3d/webgl-engine/effects/AmbientIllumination.js +1 -1
  121. package/views/3d/webgl-engine/effects/atmosphere/SimpleAtmosphere.glsl.js +1 -1
  122. package/views/3d/webgl-engine/effects/clouds/CloudsComposition.glsl.js +1 -1
  123. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
  124. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  125. package/views/3d/webgl-engine/effects/laserlines/LaserlinePath.glsl.js +1 -1
  126. package/views/3d/webgl-engine/effects/precipitation/Precipitation.glsl.js +1 -1
  127. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  128. package/views/3d/webgl-engine/effects/stars/DeepSky.glsl.js +1 -1
  129. package/views/3d/webgl-engine/effects/stars/Stars.glsl.js +1 -1
  130. package/views/3d/webgl-engine/lib/LineMaterial.js +1 -1
  131. package/views/3d/webgl-engine/lib/Program.js +1 -1
  132. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  133. package/views/3d/webgl-engine/lib/edgeRendering/AdjustProjectedPosition.glsl.js +4 -4
  134. package/views/3d/webgl-engine/lib/edgeRendering/EdgeShader.glsl.js +1 -1
  135. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  136. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  137. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  138. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  139. package/views/3d/webgl-engine/materials/Path.glsl.js +1 -1
  140. package/views/3d/webgl-engine/materials/PolygonOffset.js +1 -1
  141. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  142. package/views/3d/webgl-engine/materials/ViewingModeConfiguration.js +1 -1
  143. package/views/3d/webgl-engine/materials/Water.glsl.js +1 -1
  144. package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
  145. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  146. package/views/3d/webgl-engine/shaders/ColorMaterial.glsl.js +1 -1
  147. package/views/3d/webgl-engine/shaders/Compositing.glsl.js +1 -1
  148. package/views/3d/webgl-engine/shaders/GaussianSplatPass.glsl.js +26 -26
  149. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  150. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  151. package/views/3d/webgl-engine/shaders/LineCallout.glsl.js +1 -1
  152. package/views/3d/webgl-engine/shaders/LineCalloutTechniqueConfiguration.js +1 -1
  153. package/views/3d/webgl-engine/shaders/LineMarker.glsl.js +1 -1
  154. package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
  155. package/views/3d/webgl-engine/shaders/LineMarkerTechniqueConfiguration.js +1 -1
  156. package/views/3d/webgl-engine/shaders/LineTechniqueConfiguration.js +2 -0
  157. package/views/3d/webgl-engine/shaders/MeasurementArrowTechniqueConfiguration.js +1 -1
  158. package/views/3d/webgl-engine/shaders/NativeLineTechniqueConfiguration.js +1 -1
  159. package/views/3d/webgl-engine/shaders/NavigationDepth.glsl.js +1 -1
  160. package/views/3d/webgl-engine/shaders/OccludedGeometryDepth.glsl.js +1 -1
  161. package/views/3d/webgl-engine/shaders/PointRenderer.glsl.js +1 -1
  162. package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
  163. package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
  164. package/views/3d/webgl-engine/shaders/ScreenSpacePassAtmosphere.glsl.js +1 -1
  165. package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
  166. package/views/3d/webgl-engine/shaders/Viewshed.glsl.js +1 -1
  167. package/views/3d/webgl-engine/shaders/VolumeMask.glsl.js +1 -1
  168. package/widgets/ElevationProfile/ElevationProfileLineQuery.d.ts +1 -1
  169. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  170. package/widgets/ValuePicker.d.ts +1 -1
  171. package/widgets/ValuePicker.js +1 -1
  172. package/widgets/VideoPlayer/VideoPlayerViewModel.d.ts +4 -2
  173. package/widgets/VideoPlayer/VideoPlayerViewModel.js +1 -1
  174. package/widgets/VideoPlayer.js +1 -1
  175. package/assets/esri/core/workers/chunks/0630e650abdfea1792e4.js +0 -1
  176. package/assets/esri/core/workers/chunks/0edebc6c516f0b9dac7b.js +0 -1
  177. package/assets/esri/core/workers/chunks/25c5e1b14b184b1228a3.js +0 -1
  178. package/assets/esri/core/workers/chunks/573e8fa0af8711ffec45.js +0 -1
  179. package/assets/esri/core/workers/chunks/5b9925f23d4b10a7087e.js +0 -1
  180. package/assets/esri/core/workers/chunks/66c46c5a7147550ea3ed.js +0 -1
  181. package/assets/esri/core/workers/chunks/6c7cb7974969e3167f2b.js +0 -1
  182. package/assets/esri/core/workers/chunks/7bbc3d22383388d11345.js +0 -1
  183. package/assets/esri/core/workers/chunks/7edf57e31ff07af9032b.js +0 -1
  184. package/assets/esri/core/workers/chunks/8bd187b48a4e4296e3d8.js +0 -1
  185. package/assets/esri/core/workers/chunks/9acaabe950319d031f2e.js +0 -1
  186. package/assets/esri/core/workers/chunks/ac02df176f9ea94278bb.js +0 -1
  187. package/assets/esri/core/workers/chunks/b4222152efaf73b37b53.js +0 -1
  188. package/assets/esri/core/workers/chunks/c0855be20ffcd52c7026.js +0 -1
  189. package/assets/esri/core/workers/chunks/e606be4ece4eac1e9bbe.js +0 -1
  190. package/assets/esri/core/workers/chunks/f05622413cadfd14553e.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../request.js";import{has}from"../applications/Components/baUtils.js";import i from"../core/Accessor.js";import s from"../core/Error.js";import r from"../core/Logger.js";import{someMap as a}from"../core/MapUtils.js";import{createAbortError as n,isAborted as o,isAbortError as l}from"../core/promiseUtils.js";import d from"../core/ReactiveMap.js";import{watch as h}from"../core/reactiveUtils.js";import{property as _,subclass as y}from"../core/accessorSupport/decorators.js";import u from"../geometry/SpatialReference.js";import{isGeographic as c}from"../geometry/support/spatialReferenceUtils.js";import g from"../geometry/support/WKIDUnitConversion.js";import{wasmFailedToInit as m,elevQueriesFull as p,elevQueriesGenericFail as w,invalidLayerView as f}from"./ILyr3DWasmPerSceneView.js";import{Lyr3DWorkerHandle as b}from"./Lyr3DWorkerHandle.js";import{getVCSFromHeightModelInfo as v}from"./support/tiles3DUtils.js";import{loadLyr3DMainWASM as L}from"../libs/lyr3d/Lyr3DModule.js";import{getElevationOffsetInMeters as D}from"../support/elevationInfoUtils.js";import{makeScheduleFunction as C}from"../views/3d/layers/support/makeScheduleFunction.js";import{TaskPriority as M}from"../views/support/Scheduler.js";import{Yield as R}from"../views/support/Yield.js";const k=3857,S=32662,V=4326,I=5773;let W=class extends i{get _frozen(){return this._frozenLayerViewCount>0}constructor(e){super(e),this._lyr3DMainPromise=null,this._lyr3DMain=null,this._layers=new Map,this._viewSR=null,this._haveAddedViewSRForNoOpPrj=!1,this._lyr3DBusyCount=0,this._lyr3DInternalMemoryBytes=0,this._isTerrainReady=!1,this._hasLayerThatReplacesTerrain=!1,this._frozenLayerViewCount=0,this._elevationQueries=new d,this._pendingJobCompleted=new Array,this._pendingJobFailed=new Array,this._pendingRenderableCreated=new Array,this._jobDataBufferPtr=0,this._jobDataBufferCapacity=0,this._debugFlags=new Set,this._debugLevel=2,this._wasmNotLoaded="method requiring WASM was called when WASM isn't loaded",this._pulseTaskHandle=null,this._cameraDirty=!0,this._cameraElevationDirty=!0,this._debugFlags.add(0),this._debugFlags.add(1),this._debugFlags.add(2)}_debugLog(e,t,i,s=!0){if(this._debugFlags.has(e)&&this._debugLevel>=t){const e=s?`[js] ${i}`:`${i}`;0===t||1===t?r.getLogger(this).error(e):2===t&&r.getLogger(this).warn(e),r.getLogger(this).info(e)}}get viewSR(){return this._viewSR}get lyr3DInternalMemoryBytes(){return this._lyr3DInternalMemoryBytes}initialize(){this._debugLevel>2&&(r.getLogger(this).level="info"),this._debugLog(0,3,"Lyr3DWasmPerSceneView.initialize()"),this.addHandles([h(()=>this.view.state?.contentCamera,()=>this._updateWasmCamera()),h(()=>this.view.state?.contentCamera.relativeElevation,()=>this._updateWasmCameraElevation()),this.view.resourceController.addUpdatingObject(this)]),this._pulseTaskHandle=this.view.resourceController.scheduler.registerTask(M.LYR3D,this)}destroy(){this._debugLog(0,3,"Lyr3DWasmPerSceneView.destroy()"),this._lyr3DMain&&(this._jobDataBufferPtr&&(this._lyr3DMain._free(this._jobDataBufferPtr),this._jobDataBufferPtr=0,this._jobDataBufferCapacity=0),this._layers.forEach(e=>{e.abortController.abort()}),this._elevationQueries.forEach((e,t)=>{this._lyr3DMain.cancel_elevation_query(t),e.rejectCallback(n())}),this._elevationQueries.clear(),this._lyr3DMain.uninitialize_lyr3d_wasm(),this._lyr3DMain=null),this._pendingJobCompleted.length=0,this._pendingJobFailed.length=0,this._pendingRenderableCreated.length=0;const e=this._workerHandle;e&&e.destroyWasm().then(()=>{this._workerHandle?.destroy(),this._workerHandle=null}),this._pulseTaskHandle?.remove(),this._pulseTaskHandle=null}get readyToRun(){return this._hasPendingPulseWork()}get updating(){return this._elevationQueries.size>0}runTask(e){return this._pulseTask(e),R}_hasPendingPulseWork(){return!!this._lyr3DMain&&(!this._frozen&&this._cameraDirty||!this._frozen&&this._cameraElevationDirty||this._pendingJobCompleted.length>0||this._pendingJobFailed.length>0||this._pendingRenderableCreated.length>0||this._elevationQueries.size>0||a(this._layers,e=>this._isUpdating(e)))}addLayerView(e){return this._lyr3DMain?this._addLayerView(e):(this._debugLog(0,1,"Lyr3DWasmPerSceneView.add3DTilesLayerView() called when WASM wasn't initialized"),{wasmLayerId:m})}removeLayerView(e){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),0;this._is3DTilesIMLayerView(e)&&e.freeze&&this.decrementFrozenLayerViewCount(e),this._doRemoveLayerView(e);const t=this._layers.size;return 0===t&&(this._debugLog(0,3,"Lyr3DWasmPerSceneView.remove3DTilesLayerView() no Lyr3D layers left after removing a layer, destroying"),this.destroy()),t}getValidLayerViewCount(){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),0;let e=0;return this._layers.forEach(t=>{t.layerView.wasmLayerId>=0&&++e}),e}setEnabled(e,t){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const i=this._layers.get(e.wasmLayerId);if(i){this._lyr3DMain.set_enabled(e.wasmLayerId,t),i.needMemoryUsageUpdate=!0;const s=this._isUpdating(i);i.needFrame=!0,s||i.layerView.updatingFlagChanged()}}setLayerOffset(e,t){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const i=this._layers.get(e.wasmLayerId);i&&(this._lyr3DMain.set_carto_offset_z(e.wasmLayerId,t),i.needFrame=!0,i.layerView.updatingFlagChanged())}getAttributionText(){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),[];return this._lyr3DMain.get_current_attribution_text().split("|")}onRenderableEvicted(e,t,i){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);this._layers.get(e.wasmLayerId)&&this._lyr3DMain.on_renderable_evicted(e.wasmLayerId,t,i)}setMeshModifications(e,t){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const i=this._layers.get(e.wasmLayerId);if(i){this._lyr3DMain.set_mesh_modification_polygons(e.wasmLayerId,t);const s=this._isUpdating(i);i.needFrame=!0,s||i.layerView.updatingFlagChanged()}}isUpdating(e){if(!this._lyr3DMain&&this._lyr3DMainPromise)return!0;const t=this._layers.get(e);return!!t&&this._isUpdating(t)}incrementFrozenLayerViewCount(e){this._layers.has(e.wasmLayerId)&&(this._frozenLayerViewCount+=1)}decrementFrozenLayerViewCount(e){this._layers.has(e.wasmLayerId)&&(this._frozenLayerViewCount-=1)}initializeWasm(e,t){return this._lyr3DMain?Promise.resolve():this.view.renderSpatialReference?(this._debugLog(0,3,"Lyr3DWasmPerSceneView.initializeWasm()"),this._lyr3DMainPromise||(this._lyr3DMainPromise=L().then(i=>{this._lyr3DMain=i,this._lyr3DMainPromise=null;const s=this._lyr3DMain.addFunction(this._onNewJob.bind(this),"vi"),r=this._lyr3DMain.addFunction(this._onNewRenderable.bind(this),"vi"),a=this._lyr3DMain.addFunction(this._freeRenderables.bind(this),"vi"),n=this._lyr3DMain.addFunction(this._setRenderableVisibility.bind(this),"vi"),o=this._lyr3DMain.addFunction(this._onWasmError.bind(this),"viiii"),l=this._lyr3DMain.addFunction(this._onElevQueryComplete.bind(this),"vi");if(!this.view.renderSpatialReference)return void(this._lyr3DMain=null);this._viewSR=this.view.renderSpatialReference?.toJSON();let d="global"===this.view.viewingMode?6:4;6===d?(this._viewSR.wkid=this._viewSR.latestWkid=V,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=I,this._viewSR.wkt=""):(this._viewSR.vcsWkid||(this._viewSR.vcsWkid=v(this.view.heightModelInfo)),this.view.renderSpatialReference?.isWebMercator?(this._viewSR.wkid=this._viewSR.latestWkid=k,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=I):this.view.renderSpatialReference?.wkid===S?(this._viewSR.wkid=this._viewSR.latestWkid=V,d=3,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=I):this._viewSR.vcsWkid||this._viewSR.latestVcsWkid||(this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=-1));const h=has("esri-lyr3D-max-concurrent-requests")??16;return this._lyr3DMain.initialize_lyr3d_wasm(o,s,r,a,n,l,e,t,d,this._cleanUpSR(this._makeSRWasmSerializable(this._viewSR)),Math.max(this._debugLevel,0),h)?(this._workerHandle=new b(C(this.view.resourceController)),this._workerHandle.promise?this._workerHandle.promise:void 0):(this._lyr3DMain=null,void this._debugLog(0,0,"Lyr3d Main WASM failed to initialize",!1))}).catch(e=>{this._debugLog(0,0,`Lyr3d WASM failed to download error = ${e}`,!1)})),this._lyr3DMainPromise):Promise.reject()}get isTerrainReady(){return this._isTerrainReady}setLodPixelThreshold(e,t){this._lyr3DMain?.set_lod_pixel_threshold(t);const i=this._layers.get(e.wasmLayerId);i&&(i.needFrame=!0,i.layerView.updatingFlagChanged())}setMaximumGaussianSplatCount(e){this._lyr3DMain.set_maximum_splat_count(e),this._layers.forEach(e=>{"gaussian-splat-3d"===e.layerView.type&&(e.needFrame=!0,e.layerView.updatingFlagChanged())})}queryElevation(e,t,i){if(!this._lyr3DMain)return Promise.reject(this._wasmNotLoaded);if(0===t.coordinates.length)return Promise.reject("no coordinates for elevation query");const s="global"===this.view.viewingMode?u.WGS84:this._viewSR.wkid===k?u.WebMercator:u.PlateCarree,r=t.projectSync(s);r&&(t=r);const a=2*t.coordinates.length,n=this._lyr3DMain._malloc(8*a),o=new Float64Array(this._lyr3DMain.HEAPF64.buffer,n,a);for(let y=0;y<t.coordinates.length;++y){const e=t.coordinates[y];o[2*y]=e.x,o[2*y+1]=e.y}const l=i?.maxGeometricError??0,d=this._lyr3DMain.create_elevation_query(e.wasmLayerId,l,n,a);if(this._lyr3DMain._free(n),d===p)return Promise.reject("max mesh elevation query limit exceeded");if(d===w)return Promise.reject("elevation query failed");const h={wasmLayerId:e.wasmLayerId,descriptor:t,signal:i?.signal,resolveCallback:null,rejectCallback:null},_=new Promise((e,t)=>{h.resolveCallback=e,h.rejectCallback=t});return this._elevationQueries.set(d,h),_}_checkForAbortedElevationQueries(){const e=[];this._elevationQueries.forEach((t,i)=>{o(t.signal)&&(this._lyr3DMain.cancel_elevation_query(i),t.rejectCallback(n()),e.push(i))});for(let t=0;t<e.length;++t)this._elevationQueries.delete(e[t])}_cancelElevationQueriesForLayer(e){const t=new Array;this._elevationQueries.forEach((i,s)=>{i.wasmLayerId===e&&(this._lyr3DMain.cancel_elevation_query(s),i.rejectCallback(n()),t.push(s))}),t.forEach(e=>this._elevationQueries.delete(e))}_pulseTask(e){const t=this._lyr3DMain;if(t){if(this._frozen)return this._checkForAbortedElevationQueries(),void this._flushPendingWasmCalls(e);if(this._cameraDirty){const e=this.view.state?.contentCamera;if(e){const{eye:i,center:s,up:r,near:a,far:n,fovY:o}=e,l=[e.screenViewport[2],e.screenViewport[3]],d={eye:i,center:s,up:r,near:a,far:n,fov:o,aspectRatio:e.width/e.height,viewport:l};t.set_camera_parameters(d),this._cameraDirty=!1}}if(this._cameraElevationDirty){const e=this.view.state?.contentCamera.relativeElevation;t.set_camera_elevation(e),this._cameraElevationDirty=!1}this._checkForAbortedElevationQueries();let i=0,s=0;this._layers.forEach(e=>{i+=e.layerView.usedMemory,s+=e.layerView.cachedMemory}),i/=1048576,s/=1048576;const r=this.view.resourceController.memoryController,a=r.usedMemory*r.maxMemory-i-this._lyr3DInternalMemoryBytes/1048576;this._lyr3DBusyCount=this._lyr3DMain.frame_pulse(r.memoryFactor,i,s,a,r.maxMemory),this._lyr3DInternalMemoryBytes=this._lyr3DMain.get_index_memory_bytes(),this._layers.forEach(e=>{this._cameraElevationDirty||(e.needFrame=!1),e.layerView.updatingFlagChanged()}),this._hasLayerThatReplacesTerrain&&!this._isTerrainReady&&(this._isTerrainReady=this._lyr3DMain.is_terrain_ready(),this._isTerrainReady&&this.notifyChange("isTerrainReady")),this._flushPendingWasmCalls(e)}}_isUpdating(e){return e.outstandingJobCount>0||e.outstandingRenderableCount>0||!this._frozen&&e.needFrame||!this._frozen&&this._cameraDirty||!this._frozen&&this._cameraElevationDirty||!this._frozen&&this._lyr3DBusyCount>0}_incrementJobCount(e,t){if(t.isForElevationQuery)return;const i=this._isUpdating(e);e.outstandingJobCount+=1,i||e.layerView.updatingFlagChanged()}_decrementJobCount(e,t){if(t.isForElevationQuery)return;const i=this._isUpdating(e);e.outstandingJobCount-=1;i!==this._isUpdating(e)&&e.layerView.updatingFlagChanged()}_incrementRenderableCount(e){const t=this._isUpdating(e);e.outstandingRenderableCount+=1,t||e.layerView.updatingFlagChanged()}_decrementRenderableCount(e){const t=this._isUpdating(e);e.outstandingRenderableCount-=1;t!==this._isUpdating(e)&&e.layerView.updatingFlagChanged()}_flushPendingWasmCalls(e){this._lyr3DMain&&(this._flushPendingCalls(this._pendingJobFailed,e),this._flushPendingCalls(this._pendingJobCompleted,e),this._flushPendingCalls(this._pendingRenderableCreated,e))}_flushPendingCalls(e,t){for(;!t.done&&e.length>0;){e.shift()(this._lyr3DMain),t.madeProgress()}}_decrementJobCountIfLayerExists(e,t){this._layers.get(e.layerView.wasmLayerId)===e&&this._decrementJobCount(e,t)}_decrementRenderableCountIfLayerExists(e){this._layers.get(e.layerView.wasmLayerId)===e&&this._decrementRenderableCount(e)}_onJobFailed(e,t,i){t.error.length&&this._debugLog(1,1,t.error,!1),this._lyr3DMain&&!e.layerView.destroyed?this._pendingJobFailed.push(t=>{try{t.on_job_failed(i.jobId,i.desc)}finally{this._decrementJobCountIfLayerExists(e,i)}}):this._decrementJobCountIfLayerExists(e,i)}_onJobSucceeded(e,t,i){if(e.layerView.destroyed)return void(this._lyr3DMain?this._pendingJobFailed.push(t=>{try{t.on_job_failed(i.jobId,i.desc)}finally{this._decrementJobCountIfLayerExists(e,i)}}):this._decrementJobCountIfLayerExists(e,i));const{data:s}=t;if(this._lyr3DMain){const r=r=>{try{const e=s.byteLength,a=this._ensureJobDataBuffer(e);new Uint8Array(r.HEAPU8.buffer,a,e).set(s),r.on_job_completed(i.jobId,t.jobDescJson,a,e)}finally{this._decrementJobCountIfLayerExists(e,i)}};this._pendingJobCompleted.push(r)}else this._decrementJobCountIfLayerExists(e,i)}_ensureJobDataBuffer(e){return e<=this._jobDataBufferCapacity&&this._jobDataBufferPtr||(this._jobDataBufferPtr&&this._lyr3DMain._free(this._jobDataBufferPtr),this._jobDataBufferPtr=this._lyr3DMain._malloc(e),this._jobDataBufferCapacity=e),this._jobDataBufferPtr}_getRequestPromises(e,i,s,r){const a=[];for(const n of e){const e=new URL(n);if("integrated-mesh-3dtiles"===r.type){if(e.origin===s.origin&&e.pathname===s.pathname){if(r.rootTileset){a.push(Promise.resolve(r.rootTileset.slice()));continue}}else r.session&&e.searchParams.set("session",r.session)}a.push(t(e.toString(),i).then(e=>e.data))}return a}_getInitialPromise(e,t,i,s,r,a,n){const o=this._getRequestPromises(e.urls,t,i,s);return Promise.all(o).then(e=>(r.inputs=e,this._workerHandle.invoke(r,a))).then(e=>e).catch(t=>{let i=1;return l(t)?this._debugLog(1,2,`job ${e.jobId} was cancelled.`):n&&400===t.details?.httpStatus?(i=3,this._debugLog(1,2,"Session expired, trying to create new Session.")):this._debugLog(1,1,`job ${e.jobId} failed with error ${t}.`),{status:i,error:"",jobDescJson:"",data:new Uint8Array(0),missingInputUrls:[],inputs:[]}})}async _onNewJob(e){let t;try{t=this._lyr3DMain.Emval.toValue(e);const s=this._layers.get(t.layerId);if(!s)return;this._incrementJobCount(s,t);const r=s.abortController.signal,a=s.layerView.layer,n="integrated-mesh-3dtiles"===a.type?a.key:null,o="integrated-mesh-3dtiles"===a.type?a.session:null,d={responseType:"array-buffer",signal:r,query:{...s.customParameters,token:s.apiKey,key:n}},h={id:t.jobId,inputs:[],jobDescJson:t.desc.slice(),isMissingResourceCase:!1},_=new URL(a.url),y=e=>{if(1===e.status)this._onJobFailed(s,e,t);else if(0===e.status)this._onJobSucceeded(s,e,t);else if(2===e.status){const i=this._getRequestPromises(e.missingInputUrls,d,_,a);Promise.all(i).then(t=>{h.jobDescJson=e.jobDescJson,e.originalInputs?h.inputs=e.originalInputs:h.inputs=[],h.isMissingResourceCase=!0;for(const e of t)h.inputs.push(e);return this._workerHandle.invoke(h,r)}).then(e=>{1===e.status?this._onJobFailed(s,e,t):0===e.status&&this._onJobSucceeded(s,e,t)}).catch(e=>{l(e)?this._debugLog(1,2,`job ${t.jobId} was cancelled.`):this._debugLog(1,1,`job ${t.jobId} failed with error ${e}.`),this._lyr3DMain?this._pendingJobFailed.push(e=>{try{e.on_job_failed(t.jobId,t.desc)}finally{this._decrementJobCountIfLayerExists(s,t)}}):this._decrementJobCountIfLayerExists(s,t)})}};try{const e=await this._getInitialPromise(t,d,_,a,h,r,o);if(3===e.status&&"integrated-mesh-3dtiles"===a.type){o===a.session&&null!==a.session&&await a.requestRootAndSession(r);y(await this._getInitialPromise(t,d,_,a,h,r,a.session))}else y(e)}catch(i){i&&this._debugLog(1,1,i.toString(),!1),this._lyr3DMain?this._pendingJobFailed.push(e=>{try{e.on_job_failed(t.jobId,t.desc)}finally{this._decrementJobCountIfLayerExists(s,t)}}):this._decrementJobCountIfLayerExists(s,t)}}catch(i){i&&this._debugLog(1,1,i.toString(),!1)}}_onNewRenderable(e){try{const t=this._lyr3DMain.Emval.toValue(e),i=this._layers.get(t.layerId);i&&(this._incrementRenderableCount(i),i.layerView.createRenderable(t).then(e=>{!this._lyr3DMain||i.layerView.destroyed?this._decrementRenderableCountIfLayerExists(i):this._pendingRenderableCreated.push(s=>{try{const{layerId:i,handle:r}=t,a=e();s.on_renderable_created(!0,i,r,a.memUsageBytes,a.numGaussians??0)}finally{this._decrementRenderableCountIfLayerExists(i)}})}).catch(e=>{l(e)||this._debugLog(2,1,`createRenderable failed with error ${e}.`),!this._lyr3DMain||i.layerView.destroyed?this._decrementRenderableCountIfLayerExists(i):this._pendingRenderableCreated.push(e=>{try{const{layerId:i,handle:s}=t;e.on_renderable_created(!1,i,s,0,0)}finally{this._decrementRenderableCountIfLayerExists(i)}})}))}catch(t){t&&this._debugLog(1,1,t.toString(),!1)}}_freeRenderables(e){try{const t=this._lyr3DMain.Emval.toValue(e),i=this._layers.get(t.layerId);if(t.handles.length<1||!i)return;const s=i.layerView;for(let e=0;e<t.handles.length;++e)s.freeRenderable(t.handles[e])}catch(t){t&&this._debugLog(1,1,t.toString(),!1)}}_setRenderableVisibility(e){try{const t=this._lyr3DMain.Emval.toValue(e),i=this._layers.get(t.layerId);if(t.handles.length<1||t.visibility.length!==t.handles.length||!i)return;const s=i.layerView,r=[],a=[];for(let e=0;e<t.handles.length;++e)r.push(t.handles[e]),a.push(!!(1&t.visibility[e]));s.setRenderableVisibility(r,a,t.handles.length)}catch(t){t&&this._debugLog(1,1,t.toString(),!1)}}_onWasmError(e,t,i,s){if(this._lyr3DMain)try{this._debugLog(i,s,this._lyr3DMain.UTF8ToString(e,t),!1)}catch(r){}}_onElevQueryComplete(e){try{const t=this._lyr3DMain.Emval.toValue(e),{queryId:i}=t,r=this._elevationQueries.get(i);if(!r)return void this._debugLog(2,1,`_onElevQueryComplete called for unknown queryId ${i}.`);if(t.succeeded&&t.zs){const{zs:e}=t,s=r.descriptor.clone();for(let t=0;t<e.length;++t)s.coordinates[t].z=e[t];this._debugLog(2,3,`Success EQ ${i}, number points ${e.length}.`),r.resolveCallback(s),this._elevationQueries.delete(i)}else r.rejectCallback(new s("elevation-query:error",t?.error??"Elevation query failed")),this._elevationQueries.delete(i)}catch(t){t&&this._debugLog(1,1,t.toString(),!1)}}_doRemoveLayerView(e){const t=this._layers.get(e.wasmLayerId);return!!t&&(t.abortController.abort(),this._cancelElevationQueriesForLayer(e.wasmLayerId),this._lyr3DMain.remove_layer(e.wasmLayerId),this._is3DTilesIMLayerView(e)&&e.layer.replacesTerrain&&(this._hasLayerThatReplacesTerrain=!1,this._isTerrainReady=!1,this.notifyChange("isTerrainReady")),this._layers.delete(e.wasmLayerId),!0)}_is3DTilesIMLayerView(e){return"integrated-mesh-3dtiles"===e.layer.type}_is3DTilesIMLayer(e){return"integrated-mesh-3dtiles"===e.type}_isGaussianSplatLayerView(e){return"gaussian-splat"===e.layer.type}_isGaussianSplatLayer(e){return"gaussian-splat"===e.type}_toWasmQuality(e){switch(e){case"low":return 1;case"medium":return 2;case"high":return 3}}_addLayerView(e){const t=e.layer;if(!t.url||!t.rootTilesetJSON)return{wasmLayerId:f};const i="integrated-mesh-3dtiles"===t.type?0:2,s=this._lyr3DMain.validate_root_tileset(JSON.stringify(t.rootTilesetJSON),i);if(0!==s.errorCode)return{wasmLayerId:f,check:s};const a=this._lyr3DMain.get_next_layer_id(),n=new AbortController;this._layers.set(a,{layerView:e,abortController:n,needMemoryUsageUpdate:!1,outstandingJobCount:0,outstandingRenderableCount:0,customParameters:t.customParameters,apiKey:t.apiKey,needFrame:!0});const o=D(t.elevationInfo),l=this._toWasmQuality(this.view?.qualityProfile),d=e=>r.getLogger(this).error("add-spatial-reference-error","Error when adding SR:",e);let h=!1;if(this._isGaussianSplatLayerView(e)&&this._isGaussianSplatLayer(t)||this._is3DTilesIMLayerView(e)&&this._is3DTilesIMLayer(t)){let i=t.spatialReference;if(e.useEsriCrs&&t.esriCrsSpatialReference){i=t.esriCrsSpatialReference;const s=c(i);let r=1,a=1;!s&&i.wkid&&-1!==i.wkid&&(r=g.values[g[i.wkid]],a=e.metersPerVCSUnit),this._workerHandle.addSpatialReferenceInfo(this._cleanUpSR(this._makeSRWasmSerializable(i)),s,r,a).catch(d),!this._haveAddedViewSRForNoOpPrj&&i.vcsWkid&&this._viewSR.vcsWkid&&-1!==this._viewSR.vcsWkid&&this._viewSR.vcsWkid!==i.vcsWkid&&(this._workerHandle.addSpatialReferenceInfo(this._cleanUpSR(this._makeSRWasmSerializable(this._viewSR)),!1,1,1).catch(d),this._haveAddedViewSRForNoOpPrj=!0)}this._isGaussianSplatLayerView(e)?h=this._lyr3DMain.add_gaussian_splat_layer(l,t.url,a,o):this._is3DTilesIMLayerView(e)&&(h=this._lyr3DMain.add_3dtiles_layer(l,t.url,a,o,e.layer.replacesTerrain),h&&e.layer.replacesTerrain&&(this._hasLayerThatReplacesTerrain=!0,this._isTerrainReady=!1,this.notifyChange("isTerrainReady")))}return h?(this._updateWasmCamera(),this._is3DTilesIMLayerView(e)&&e.freeze&&this.incrementFrozenLayerViewCount(e),e.updatingFlagChanged(),{wasmLayerId:a}):(this._layers.delete(a),{wasmLayerId:f})}_updateWasmCamera(){const e=this.view.state?.contentCamera;e&&this._lyr3DMain&&(this._cameraDirty=!0,this._frozen||this._markAllLayerViewsUpdating())}_updateWasmCameraElevation(){this._cameraElevationDirty=!0,this._frozen||this._markAllLayerViewsUpdating()}_markAllLayerViewsUpdating(){this._layers.forEach(e=>{const t=this._isUpdating(e);e.needFrame=!0,t||e.layerView.updatingFlagChanged()})}_makeSRWasmSerializable(e){return{wkid:e?.wkid??-1,latestWkid:e?.latestWkid??-1,vcsWkid:e?.vcsWkid??-1,latestVcsWkid:e?.latestVcsWkid??-1,wkt:e?.wkt??""}}_cleanUpSR(e){return-1===e?.wkid&&e.latestWkid&&-1!==e.latestWkid?e.wkid=e.latestWkid:-1===e?.latestWkid&&e.wkid&&-1!==e.wkid&&(e.latestWkid=e.wkid),-1===e?.vcsWkid&&e.latestVcsWkid&&-1!==e.latestVcsWkid?e.vcsWkid=e.latestVcsWkid:-1===e?.latestVcsWkid&&e.vcsWkid&&-1!==e.vcsWkid&&(e.latestVcsWkid=e.vcsWkid),e}};e([_({constructOnly:!0})],W.prototype,"view",void 0),e([_()],W.prototype,"updating",null),e([_({readOnly:!0})],W.prototype,"isTerrainReady",null),W=e([y("esri.layers.Lyr3DWasmPerSceneView")],W);const j=W;export{j as default};
2
+ import{__decorate as e}from"tslib";import t from"../request.js";import{has}from"../applications/Components/baUtils.js";import i from"../core/Accessor.js";import s from"../core/Error.js";import r from"../core/Logger.js";import{someMap as a}from"../core/MapUtils.js";import{createAbortError as n,isAborted as o,isAbortError as l}from"../core/promiseUtils.js";import d from"../core/ReactiveMap.js";import{watch as h}from"../core/reactiveUtils.js";import{signal as _}from"../core/signal.js";import{property as y,subclass as u}from"../core/accessorSupport/decorators.js";import c from"../geometry/SpatialReference.js";import{isGeographic as g}from"../geometry/support/spatialReferenceUtils.js";import m from"../geometry/support/WKIDUnitConversion.js";import{wasmFailedToInit as p,elevQueriesFull as f,elevQueriesGenericFail as w,invalidLayerView as b}from"./ILyr3DWasmPerSceneView.js";import{Lyr3DWorkerHandle as v}from"./Lyr3DWorkerHandle.js";import{getVCSFromHeightModelInfo as L}from"./support/tiles3DUtils.js";import{loadLyr3DMainWASM as D}from"../libs/lyr3d/Lyr3DModule.js";import{getElevationOffsetInMeters as C}from"../support/elevationInfoUtils.js";import{makeScheduleFunction as M}from"../views/3d/layers/support/makeScheduleFunction.js";import{TaskPriority as R}from"../views/support/Scheduler.js";import{Yield as k}from"../views/support/Yield.js";const S=3857,V=32662,I=4326,W=5773;let j=class extends i{get _frozen(){return this._frozenLayerViewCount>0}constructor(e){super(e),this._lyr3DMainPromise=null,this._lyr3DMain=null,this._layers=new Map,this._viewSR=null,this._haveAddedViewSRForNoOpPrj=!1,this._lyr3DBusyCount=0,this._lyr3DInternalMemoryBytes=0,this._isTerrainReady=!1,this._hasLayerThatReplacesTerrain=!1,this._frozenLayerViewCount=0,this._elevationQueries=new d,this._pendingJobCompleted=new Array,this._pendingJobFailed=new Array,this._pendingRenderableCreated=new Array,this._pulseDeferred=_(!1),this._jobDataBufferPtr=0,this._jobDataBufferCapacity=0,this._debugFlags=new Set,this._debugLevel=2,this._wasmNotLoaded="method requiring WASM was called when WASM isn't loaded",this._pulseTaskHandle=null,this._cameraDirty=!0,this._cameraElevationDirty=!0,this._debugFlags.add(0),this._debugFlags.add(1),this._debugFlags.add(2)}_debugLog(e,t,i,s=!0){if(this._debugFlags.has(e)&&this._debugLevel>=t){const e=s?`[js] ${i}`:`${i}`;0===t||1===t?r.getLogger(this).error(e):2===t&&r.getLogger(this).warn(e),r.getLogger(this).info(e)}}get viewSR(){return this._viewSR}get lyr3DInternalMemoryBytes(){return this._lyr3DInternalMemoryBytes}initialize(){this._debugLevel>2&&(r.getLogger(this).level="info"),this._debugLog(0,3,"Lyr3DWasmPerSceneView.initialize()"),this.addHandles([h(()=>this.view.state?.contentCamera,()=>this._updateWasmCamera()),h(()=>this.view.state?.contentCamera.relativeElevation,()=>this._updateWasmCameraElevation()),this.view.resourceController.addUpdatingObject(this)]),this._pulseTaskHandle=this.view.resourceController.scheduler.registerTask(R.LYR3D,this)}destroy(){this._debugLog(0,3,"Lyr3DWasmPerSceneView.destroy()"),this._lyr3DMain&&(this._jobDataBufferPtr&&(this._lyr3DMain._free(this._jobDataBufferPtr),this._jobDataBufferPtr=0,this._jobDataBufferCapacity=0),this._layers.forEach(e=>{e.abortController.abort()}),this._elevationQueries.forEach((e,t)=>{this._lyr3DMain.cancel_elevation_query(t),e.rejectCallback(n())}),this._elevationQueries.clear(),this._lyr3DMain.uninitialize_lyr3d_wasm(),this._lyr3DMain=null),this._pendingJobCompleted.length=0,this._pendingJobFailed.length=0,this._pendingRenderableCreated.length=0;const e=this._workerHandle;e&&e.destroyWasm().then(()=>{this._workerHandle?.destroy(),this._workerHandle=null}),this._pulseTaskHandle?.remove(),this._pulseTaskHandle=null}get readyToRun(){return this._hasPendingPulseWork()}get updating(){return this._elevationQueries.size>0}runTask(e){return this._pulseTask(e),k}_hasPendingPulseWork(){return!!this._lyr3DMain&&(!this._frozen&&this._cameraDirty||!this._frozen&&this._cameraElevationDirty||this._pendingJobCompleted.length>0||this._pendingJobFailed.length>0||this._pendingRenderableCreated.length>0||this._elevationQueries.size>0||a(this._layers,e=>this._isUpdating(e)))}addLayerView(e){return this._lyr3DMain?this._addLayerView(e):(this._debugLog(0,1,"Lyr3DWasmPerSceneView.add3DTilesLayerView() called when WASM wasn't initialized"),{wasmLayerId:p})}removeLayerView(e){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),0;this._is3DTilesIMLayerView(e)&&e.freeze&&this.decrementFrozenLayerViewCount(e),this._doRemoveLayerView(e);const t=this._layers.size;return 0===t&&(this._debugLog(0,3,"Lyr3DWasmPerSceneView.remove3DTilesLayerView() no Lyr3D layers left after removing a layer, destroying"),this.destroy()),t}getValidLayerViewCount(){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),0;let e=0;return this._layers.forEach(t=>{t.layerView.wasmLayerId>=0&&++e}),e}setEnabled(e,t){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const i=this._layers.get(e.wasmLayerId);if(i){this._lyr3DMain.set_enabled(e.wasmLayerId,t),i.needMemoryUsageUpdate=!0;const s=this._isUpdating(i);i.needFrame=!0,s||i.layerView.updatingFlagChanged()}}setLayerOffset(e,t){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const i=this._layers.get(e.wasmLayerId);i&&(this._lyr3DMain.set_carto_offset_z(e.wasmLayerId,t),i.needFrame=!0,i.layerView.updatingFlagChanged())}getAttributionText(){if(!this._lyr3DMain)return this._debugLog(0,1,this._wasmNotLoaded),[];return this._lyr3DMain.get_current_attribution_text().split("|")}onRenderableEvicted(e,t,i){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);this._layers.get(e.wasmLayerId)&&this._lyr3DMain.on_renderable_evicted(e.wasmLayerId,t,i)}setMeshModifications(e,t){if(!this._lyr3DMain)return void this._debugLog(0,1,this._wasmNotLoaded);const i=this._layers.get(e.wasmLayerId);if(i){this._lyr3DMain.set_mesh_modification_polygons(e.wasmLayerId,t);const s=this._isUpdating(i);i.needFrame=!0,s||i.layerView.updatingFlagChanged()}}isUpdating(e){if(!this._lyr3DMain&&this._lyr3DMainPromise)return!0;const t=this._layers.get(e);return!!t&&this._isUpdating(t)}incrementFrozenLayerViewCount(e){this._layers.has(e.wasmLayerId)&&(this._frozenLayerViewCount+=1)}decrementFrozenLayerViewCount(e){this._layers.has(e.wasmLayerId)&&(this._frozenLayerViewCount-=1)}initializeWasm(e,t){return this._lyr3DMain?Promise.resolve():this.view.renderSpatialReference?(this._debugLog(0,3,"Lyr3DWasmPerSceneView.initializeWasm()"),this._lyr3DMainPromise||(this._lyr3DMainPromise=D().then(i=>{this._lyr3DMain=i,this._lyr3DMainPromise=null;const s=this._lyr3DMain.addFunction(this._onNewJob.bind(this),"vi"),r=this._lyr3DMain.addFunction(this._onNewRenderable.bind(this),"vi"),a=this._lyr3DMain.addFunction(this._freeRenderables.bind(this),"vi"),n=this._lyr3DMain.addFunction(this._setRenderableVisibility.bind(this),"vi"),o=this._lyr3DMain.addFunction(this._onWasmError.bind(this),"viiii"),l=this._lyr3DMain.addFunction(this._onElevQueryComplete.bind(this),"vi");if(!this.view.renderSpatialReference)return void(this._lyr3DMain=null);this._viewSR=this.view.renderSpatialReference?.toJSON();let d="global"===this.view.viewingMode?6:4;6===d?(this._viewSR.wkid=this._viewSR.latestWkid=I,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=W,this._viewSR.wkt=""):(this._viewSR.vcsWkid||(this._viewSR.vcsWkid=L(this.view.heightModelInfo)),this.view.renderSpatialReference?.isWebMercator?(this._viewSR.wkid=this._viewSR.latestWkid=S,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=W):this.view.renderSpatialReference?.wkid===V?(this._viewSR.wkid=this._viewSR.latestWkid=I,d=3,this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=W):this._viewSR.vcsWkid||this._viewSR.latestVcsWkid||(this._viewSR.vcsWkid=this._viewSR.latestVcsWkid=-1));const h=has("esri-lyr3D-max-concurrent-requests")??16;return this._lyr3DMain.initialize_lyr3d_wasm(o,s,r,a,n,l,e,t,d,this._cleanUpSR(this._makeSRWasmSerializable(this._viewSR)),Math.max(this._debugLevel,0),h)?(this._workerHandle=new v(M(this.view.resourceController)),this._workerHandle.promise?this._workerHandle.promise:void 0):(this._lyr3DMain=null,void this._debugLog(0,0,"Lyr3d Main WASM failed to initialize",!1))}).catch(e=>{this._debugLog(0,0,`Lyr3d WASM failed to download error = ${e}`,!1)})),this._lyr3DMainPromise):Promise.reject()}get isTerrainReady(){return this._isTerrainReady}setLodPixelThreshold(e,t){this._lyr3DMain?.set_lod_pixel_threshold(t);const i=this._layers.get(e.wasmLayerId);i&&(i.needFrame=!0,i.layerView.updatingFlagChanged())}setMaximumGaussianSplatCount(e){this._lyr3DMain.set_maximum_splat_count(e),this._layers.forEach(e=>{"gaussian-splat-3d"===e.layerView.type&&(e.needFrame=!0,e.layerView.updatingFlagChanged())})}queryElevation(e,t,i){if(!this._lyr3DMain)return Promise.reject(this._wasmNotLoaded);if(0===t.coordinates.length)return Promise.reject("no coordinates for elevation query");const s="global"===this.view.viewingMode?c.WGS84:this._viewSR.wkid===S?c.WebMercator:c.PlateCarree,r=t.projectSync(s);r&&(t=r);const a=2*t.coordinates.length,n=this._lyr3DMain._malloc(8*a),o=new Float64Array(this._lyr3DMain.HEAPF64.buffer,n,a);for(let y=0;y<t.coordinates.length;++y){const e=t.coordinates[y];o[2*y]=e.x,o[2*y+1]=e.y}const l=i?.maxGeometricError??0,d=this._lyr3DMain.create_elevation_query(e.wasmLayerId,l,n,a);if(this._lyr3DMain._free(n),d===f)return Promise.reject("max mesh elevation query limit exceeded");if(d===w)return Promise.reject("elevation query failed");const h={wasmLayerId:e.wasmLayerId,descriptor:t,signal:i?.signal,resolveCallback:null,rejectCallback:null},_=new Promise((e,t)=>{h.resolveCallback=e,h.rejectCallback=t});return this._elevationQueries.set(d,h),_}_checkForAbortedElevationQueries(){const e=[];this._elevationQueries.forEach((t,i)=>{o(t.signal)&&(this._lyr3DMain.cancel_elevation_query(i),t.rejectCallback(n()),e.push(i))});for(let t=0;t<e.length;++t)this._elevationQueries.delete(e[t])}_cancelElevationQueriesForLayer(e){const t=new Array;this._elevationQueries.forEach((i,s)=>{i.wasmLayerId===e&&(this._lyr3DMain.cancel_elevation_query(s),i.rejectCallback(n()),t.push(s))}),t.forEach(e=>this._elevationQueries.delete(e))}_pulseTask(e){const t=this._lyr3DMain;if(t){if(this._frozen)return this._checkForAbortedElevationQueries(),void this._flushPendingWasmCalls(e);if(this._cameraDirty){const e=this.view.state?.contentCamera;if(e){const{eye:i,center:s,up:r,near:a,far:n,fovY:o}=e,l=[e.screenViewport[2],e.screenViewport[3]],d={eye:i,center:s,up:r,near:a,far:n,fov:o,aspectRatio:e.width/e.height,viewport:l};t.set_camera_parameters(d),this._cameraDirty=!1}}if(this._cameraElevationDirty){const e=this.view.state?.contentCamera.relativeElevation;t.set_camera_elevation(e),this._cameraElevationDirty=!1}if(this._checkForAbortedElevationQueries(),!this._pulseDeferred.value&&(this._flushPendingWasmCalls(e),e.done))return;let i=0,s=0;this._layers.forEach(e=>{i+=e.layerView.usedMemory,s+=e.layerView.cachedMemory}),i/=1048576,s/=1048576;const r=this.view.resourceController.memoryController,a=r.usedMemory*r.maxMemory-i-this._lyr3DInternalMemoryBytes/1048576;this._lyr3DBusyCount=this._lyr3DMain.frame_pulse(r.memoryFactor,i,s,a,r.maxMemory),this._pulseDeferred.value=!1,this._lyr3DInternalMemoryBytes=this._lyr3DMain.get_index_memory_bytes(),this._layers.forEach(e=>{this._cameraElevationDirty||(e.needFrame=!1),e.layerView.updatingFlagChanged()}),this._hasLayerThatReplacesTerrain&&!this._isTerrainReady&&(this._isTerrainReady=this._lyr3DMain.is_terrain_ready(),this._isTerrainReady&&this.notifyChange("isTerrainReady")),e.madeProgress(),this._flushPendingWasmCalls(e)}}_isUpdating(e){return e.outstandingJobCount>0||e.outstandingRenderableCount>0||!this._frozen&&(e.needFrame||this._cameraDirty||this._cameraElevationDirty||this._pulseDeferred.value||this._lyr3DBusyCount>0)}_incrementJobCount(e,t){if(t.isForElevationQuery)return;const i=this._isUpdating(e);e.outstandingJobCount+=1,i||e.layerView.updatingFlagChanged()}_decrementJobCount(e,t){if(t.isForElevationQuery)return;const i=this._isUpdating(e);e.outstandingJobCount-=1;i!==this._isUpdating(e)&&e.layerView.updatingFlagChanged()}_incrementRenderableCount(e){const t=this._isUpdating(e);e.outstandingRenderableCount+=1,t||e.layerView.updatingFlagChanged()}_decrementRenderableCount(e){const t=this._isUpdating(e);e.outstandingRenderableCount-=1;t!==this._isUpdating(e)&&e.layerView.updatingFlagChanged()}_flushPendingWasmCalls(e){this._lyr3DMain&&(this._flushPendingCalls(this._pendingJobFailed,e),this._flushPendingCalls(this._pendingJobCompleted,e),this._flushPendingCalls(this._pendingRenderableCreated,e))}_flushPendingCalls(e,t){for(;!t.done&&e.length>0;){const i=e.shift();this._pulseDeferred.value=!0,i(this._lyr3DMain),t.madeProgress()}}_decrementJobCountIfLayerExists(e,t){this._layers.get(e.layerView.wasmLayerId)===e&&this._decrementJobCount(e,t)}_decrementRenderableCountIfLayerExists(e){this._layers.get(e.layerView.wasmLayerId)===e&&this._decrementRenderableCount(e)}_onJobFailed(e,t,i){t.error.length&&this._debugLog(1,1,t.error,!1),this._lyr3DMain&&!e.layerView.destroyed?this._pendingJobFailed.push(t=>{try{t.on_job_failed(i.jobId,i.desc)}finally{this._decrementJobCountIfLayerExists(e,i)}}):this._decrementJobCountIfLayerExists(e,i)}_onJobSucceeded(e,t,i){if(e.layerView.destroyed)return void(this._lyr3DMain?this._pendingJobFailed.push(t=>{try{t.on_job_failed(i.jobId,i.desc)}finally{this._decrementJobCountIfLayerExists(e,i)}}):this._decrementJobCountIfLayerExists(e,i));const{data:s}=t;if(this._lyr3DMain){const r=r=>{try{const e=s.byteLength,a=this._ensureJobDataBuffer(e);new Uint8Array(r.HEAPU8.buffer,a,e).set(s),r.on_job_completed(i.jobId,t.jobDescJson,a,e)}finally{this._decrementJobCountIfLayerExists(e,i)}};this._pendingJobCompleted.push(r)}else this._decrementJobCountIfLayerExists(e,i)}_ensureJobDataBuffer(e){return e<=this._jobDataBufferCapacity&&this._jobDataBufferPtr||(this._jobDataBufferPtr&&this._lyr3DMain._free(this._jobDataBufferPtr),this._jobDataBufferPtr=this._lyr3DMain._malloc(e),this._jobDataBufferCapacity=e),this._jobDataBufferPtr}_getRequestPromises(e,i,s,r){const a=[];for(const n of e){const e=new URL(n);if("integrated-mesh-3dtiles"===r.type){if(e.origin===s.origin&&e.pathname===s.pathname){if(r.rootTileset){a.push(Promise.resolve(r.rootTileset.slice()));continue}}else r.session&&e.searchParams.set("session",r.session)}a.push(t(e.toString(),i).then(e=>e.data))}return a}_getInitialPromise(e,t,i,s,r,a,n){const o=this._getRequestPromises(e.urls,t,i,s);return Promise.all(o).then(e=>(r.inputs=e,this._workerHandle.invoke(r,a))).then(e=>e).catch(t=>{let i=1;return l(t)?this._debugLog(1,2,`job ${e.jobId} was cancelled.`):n&&400===t.details?.httpStatus?(i=3,this._debugLog(1,2,"Session expired, trying to create new Session.")):this._debugLog(1,1,`job ${e.jobId} failed with error ${t}.`),{status:i,error:"",jobDescJson:"",data:new Uint8Array(0),missingInputUrls:[],inputs:[]}})}async _onNewJob(e){let t;try{t=this._lyr3DMain.Emval.toValue(e);const s=this._layers.get(t.layerId);if(!s)return;this._incrementJobCount(s,t);const r=s.abortController.signal,a=s.layerView.layer,n="integrated-mesh-3dtiles"===a.type?a.key:null,o="integrated-mesh-3dtiles"===a.type?a.session:null,d={responseType:"array-buffer",signal:r,query:{...s.customParameters,token:s.apiKey,key:n}},h={id:t.jobId,inputs:[],jobDescJson:t.desc.slice(),isMissingResourceCase:!1},_=new URL(a.url),y=e=>{if(1===e.status)this._onJobFailed(s,e,t);else if(0===e.status)this._onJobSucceeded(s,e,t);else if(2===e.status){const i=this._getRequestPromises(e.missingInputUrls,d,_,a);Promise.all(i).then(t=>{h.jobDescJson=e.jobDescJson,e.originalInputs?h.inputs=e.originalInputs:h.inputs=[],h.isMissingResourceCase=!0;for(const e of t)h.inputs.push(e);return this._workerHandle.invoke(h,r)}).then(e=>{1===e.status?this._onJobFailed(s,e,t):0===e.status&&this._onJobSucceeded(s,e,t)}).catch(e=>{l(e)?this._debugLog(1,2,`job ${t.jobId} was cancelled.`):this._debugLog(1,1,`job ${t.jobId} failed with error ${e}.`),this._lyr3DMain?this._pendingJobFailed.push(e=>{try{e.on_job_failed(t.jobId,t.desc)}finally{this._decrementJobCountIfLayerExists(s,t)}}):this._decrementJobCountIfLayerExists(s,t)})}};try{const e=await this._getInitialPromise(t,d,_,a,h,r,o);if(3===e.status&&"integrated-mesh-3dtiles"===a.type){o===a.session&&null!==a.session&&await a.requestRootAndSession(r);y(await this._getInitialPromise(t,d,_,a,h,r,a.session))}else y(e)}catch(i){i&&this._debugLog(1,1,i.toString(),!1),this._lyr3DMain?this._pendingJobFailed.push(e=>{try{e.on_job_failed(t.jobId,t.desc)}finally{this._decrementJobCountIfLayerExists(s,t)}}):this._decrementJobCountIfLayerExists(s,t)}}catch(i){i&&this._debugLog(1,1,i.toString(),!1)}}_onNewRenderable(e){try{const t=this._lyr3DMain.Emval.toValue(e),i=this._layers.get(t.layerId);i&&(this._incrementRenderableCount(i),i.layerView.createRenderable(t).then(e=>{!this._lyr3DMain||i.layerView.destroyed?this._decrementRenderableCountIfLayerExists(i):this._pendingRenderableCreated.push(s=>{try{const{layerId:i,handle:r}=t,a=e();s.on_renderable_created(!0,i,r,a.memUsageBytes,a.numGaussians??0)}finally{this._decrementRenderableCountIfLayerExists(i)}})}).catch(e=>{l(e)||this._debugLog(2,1,`createRenderable failed with error ${e}.`),!this._lyr3DMain||i.layerView.destroyed?this._decrementRenderableCountIfLayerExists(i):this._pendingRenderableCreated.push(e=>{try{const{layerId:i,handle:s}=t;e.on_renderable_created(!1,i,s,0,0)}finally{this._decrementRenderableCountIfLayerExists(i)}})}))}catch(t){t&&this._debugLog(1,1,t.toString(),!1)}}_freeRenderables(e){try{const t=this._lyr3DMain.Emval.toValue(e),i=this._layers.get(t.layerId);if(t.handles.length<1||!i)return;const s=i.layerView;for(let e=0;e<t.handles.length;++e)s.freeRenderable(t.handles[e])}catch(t){t&&this._debugLog(1,1,t.toString(),!1)}}_setRenderableVisibility(e){try{const t=this._lyr3DMain.Emval.toValue(e),i=this._layers.get(t.layerId);if(t.handles.length<1||t.visibility.length!==t.handles.length||!i)return;const s=i.layerView,r=[],a=[];for(let e=0;e<t.handles.length;++e)r.push(t.handles[e]),a.push(!!(1&t.visibility[e]));s.setRenderableVisibility(r,a,t.handles.length)}catch(t){t&&this._debugLog(1,1,t.toString(),!1)}}_onWasmError(e,t,i,s){if(this._lyr3DMain)try{this._debugLog(i,s,this._lyr3DMain.UTF8ToString(e,t),!1)}catch(r){}}_onElevQueryComplete(e){try{const t=this._lyr3DMain.Emval.toValue(e),{queryId:i}=t,r=this._elevationQueries.get(i);if(!r)return void this._debugLog(2,1,`_onElevQueryComplete called for unknown queryId ${i}.`);if(t.succeeded&&t.zs){const{zs:e}=t,s=r.descriptor.clone();for(let t=0;t<e.length;++t)s.coordinates[t].z=e[t];this._debugLog(2,3,`Success EQ ${i}, number points ${e.length}.`),r.resolveCallback(s),this._elevationQueries.delete(i)}else r.rejectCallback(new s("elevation-query:error",t?.error??"Elevation query failed")),this._elevationQueries.delete(i)}catch(t){t&&this._debugLog(1,1,t.toString(),!1)}}_doRemoveLayerView(e){const t=this._layers.get(e.wasmLayerId);return!!t&&(t.abortController.abort(),this._cancelElevationQueriesForLayer(e.wasmLayerId),this._lyr3DMain.remove_layer(e.wasmLayerId),this._is3DTilesIMLayerView(e)&&e.layer.replacesTerrain&&(this._hasLayerThatReplacesTerrain=!1,this._isTerrainReady=!1,this.notifyChange("isTerrainReady")),this._layers.delete(e.wasmLayerId),!0)}_is3DTilesIMLayerView(e){return"integrated-mesh-3dtiles"===e.layer.type}_is3DTilesIMLayer(e){return"integrated-mesh-3dtiles"===e.type}_isGaussianSplatLayerView(e){return"gaussian-splat"===e.layer.type}_isGaussianSplatLayer(e){return"gaussian-splat"===e.type}_toWasmQuality(e){switch(e){case"low":return 1;case"medium":return 2;case"high":return 3}}_addLayerView(e){const t=e.layer;if(!t.url||!t.rootTilesetJSON)return{wasmLayerId:b};const i="integrated-mesh-3dtiles"===t.type?0:2,s=this._lyr3DMain.validate_root_tileset(JSON.stringify(t.rootTilesetJSON),i);if(0!==s.errorCode)return{wasmLayerId:b,check:s};const a=this._lyr3DMain.get_next_layer_id(),n=new AbortController;this._layers.set(a,{layerView:e,abortController:n,needMemoryUsageUpdate:!1,outstandingJobCount:0,outstandingRenderableCount:0,customParameters:t.customParameters,apiKey:t.apiKey,needFrame:!0});const o=C(t.elevationInfo),l=this._toWasmQuality(this.view?.qualityProfile),d=e=>r.getLogger(this).error("add-spatial-reference-error","Error when adding SR:",e);let h=!1;if(this._isGaussianSplatLayerView(e)&&this._isGaussianSplatLayer(t)||this._is3DTilesIMLayerView(e)&&this._is3DTilesIMLayer(t)){let i=t.spatialReference;if(e.useEsriCrs&&t.esriCrsSpatialReference){i=t.esriCrsSpatialReference;const s=g(i);let r=1,a=1;!s&&i.wkid&&-1!==i.wkid&&(r=m.values[m[i.wkid]],a=e.metersPerVCSUnit),this._workerHandle.addSpatialReferenceInfo(this._cleanUpSR(this._makeSRWasmSerializable(i)),s,r,a).catch(d),!this._haveAddedViewSRForNoOpPrj&&i.vcsWkid&&this._viewSR.vcsWkid&&-1!==this._viewSR.vcsWkid&&this._viewSR.vcsWkid!==i.vcsWkid&&(this._workerHandle.addSpatialReferenceInfo(this._cleanUpSR(this._makeSRWasmSerializable(this._viewSR)),!1,1,1).catch(d),this._haveAddedViewSRForNoOpPrj=!0)}this._isGaussianSplatLayerView(e)?h=this._lyr3DMain.add_gaussian_splat_layer(l,t.url,a,o):this._is3DTilesIMLayerView(e)&&(h=this._lyr3DMain.add_3dtiles_layer(l,t.url,a,o,e.layer.replacesTerrain),h&&e.layer.replacesTerrain&&(this._hasLayerThatReplacesTerrain=!0,this._isTerrainReady=!1,this.notifyChange("isTerrainReady")))}return h?(this._updateWasmCamera(),this._is3DTilesIMLayerView(e)&&e.freeze&&this.incrementFrozenLayerViewCount(e),e.updatingFlagChanged(),{wasmLayerId:a}):(this._layers.delete(a),{wasmLayerId:b})}_updateWasmCamera(){const e=this.view.state?.contentCamera;e&&this._lyr3DMain&&(this._cameraDirty=!0,this._frozen||this._markAllLayerViewsUpdating())}_updateWasmCameraElevation(){this._cameraElevationDirty=!0,this._frozen||this._markAllLayerViewsUpdating()}_markAllLayerViewsUpdating(){this._layers.forEach(e=>{const t=this._isUpdating(e);e.needFrame=!0,t||e.layerView.updatingFlagChanged()})}_makeSRWasmSerializable(e){return{wkid:e?.wkid??-1,latestWkid:e?.latestWkid??-1,vcsWkid:e?.vcsWkid??-1,latestVcsWkid:e?.latestVcsWkid??-1,wkt:e?.wkt??""}}_cleanUpSR(e){return-1===e?.wkid&&e.latestWkid&&-1!==e.latestWkid?e.wkid=e.latestWkid:-1===e?.latestWkid&&e.wkid&&-1!==e.wkid&&(e.latestWkid=e.wkid),-1===e?.vcsWkid&&e.latestVcsWkid&&-1!==e.latestVcsWkid?e.vcsWkid=e.latestVcsWkid:-1===e?.latestVcsWkid&&e.vcsWkid&&-1!==e.vcsWkid&&(e.latestVcsWkid=e.vcsWkid),e}};e([y({constructOnly:!0})],j.prototype,"view",void 0),e([y()],j.prototype,"updating",null),e([y({readOnly:!0})],j.prototype,"isTerrainReady",null),j=e([u("esri.layers.Lyr3DWasmPerSceneView")],j);const E=j;export{E as default};
@@ -19,6 +19,7 @@ import type { CustomParametersMixin, CustomParametersMixinProperties } from "./m
19
19
  import type { DisplayFilteredLayer, DisplayFilteredLayerProperties } from "./mixins/DisplayFilteredLayer.js";
20
20
  import type { EditBusLayer, EditBusLayerEvents } from "./mixins/EditBusLayer.js";
21
21
  import type { FeatureLayerBase, FeatureLayerBaseProperties } from "./mixins/FeatureLayerBase.js";
22
+ import type { FeatureLayerReload } from "./mixins/FeatureLayerReload.js";
22
23
  import type { OperationalLayer, OperationalLayerProperties } from "./mixins/OperationalLayer.js";
23
24
  import type { PortalLayer, PortalLayerProperties } from "./mixins/PortalLayer.js";
24
25
  import type { RefreshableLayerEvents, RefreshableLayer, RefreshableLayerProperties } from "./mixins/RefreshableLayer.js";
@@ -879,4 +880,4 @@ export default class SubtypeGroupLayer extends SubtypeGroupLayerSuperclass {
879
880
  */
880
881
  updateAttachment(feature: Graphic, attachmentId: number, attachment: HTMLFormElement | FormData, options?: AttachmentEditOptions): Promise<FeatureEditResult>;
881
882
  }
882
- declare const SubtypeGroupLayerSuperclass: typeof Layer & typeof ClonableMixin & typeof APIKeyMixin & typeof CustomParametersMixin & typeof MultiOriginJSONSupportMixin & typeof PortalLayer & typeof OperationalLayer & typeof RefreshableLayer & typeof ScaleRangeLayer & typeof TemporalLayer & typeof BlendLayer & typeof EditBusLayer & typeof DisplayFilteredLayer & typeof FeatureLayerBase
883
+ declare const SubtypeGroupLayerSuperclass: typeof Layer & typeof ClonableMixin & typeof APIKeyMixin & typeof CustomParametersMixin & typeof MultiOriginJSONSupportMixin & typeof PortalLayer & typeof OperationalLayer & typeof RefreshableLayer & typeof ScaleRangeLayer & typeof TemporalLayer & typeof BlendLayer & typeof EditBusLayer & typeof DisplayFilteredLayer & typeof FeatureLayerBase & typeof FeatureLayerReload
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{ClonableMixin as t}from"../core/Clonable.js";import r from"../core/Collection.js";import s from"../core/Error.js";import{loadAll as i}from"../core/loadAll.js";import{getOrCreateMapValue as o}from"../core/MapUtils.js";import{MultiOriginJSONSupportMixin as a}from"../core/MultiOriginJSONSupport.js";import{debounce as n,throwIfAbortError as u,whenOrAbort as l}from"../core/promiseUtils.js";import{watch as p,sync as y}from"../core/reactiveUtils.js";import{sqlAnd as d}from"../core/sql.js";import{property as c,subclass as h}from"../core/accessorSupport/decorators.js";import m from"./Layer.js";import{APIKeyMixin as f}from"./mixins/APIKeyMixin.js";import{ArcGISService as b}from"./mixins/ArcGISService.js";import{BlendLayer as g}from"./mixins/BlendLayer.js";import{CustomParametersMixin as F}from"./mixins/CustomParametersMixin.js";import{DisplayFilteredLayer as w}from"./mixins/DisplayFilteredLayer.js";import{EditBusLayer as S}from"./mixins/EditBusLayer.js";import{FeatureLayerBase as j}from"./mixins/FeatureLayerBase.js";import{OperationalLayer as v}from"./mixins/OperationalLayer.js";import{PortalLayer as L}from"./mixins/PortalLayer.js";import{RefreshableLayer as T}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as I}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as x}from"./mixins/TemporalLayer.js";import{titleFromUrlAndName as E}from"./support/arcgisLayerUrl.js";import{id as _}from"./support/commonProperties.js";import{ensureLayerCredential as O,computeEffectiveEditingEnabled as C,addAttachment as P,updateAttachment as U,applyEdits as G,createQuery as q,deleteAttachments as D,fetchRecomputedExtents as M,computeDomainFromSubtypes as A,getFeatureSubtype as k,queryAttachments as R,queryObjectIds as N,queryFeatureCount as Q,queryExtent as $,queryRelatedFeatures as H,queryRelatedFeaturesCount as J,hasDataChanged as V}from"./support/featureLayerUtils.js";import{defineFieldProperties as B}from"./support/fieldProperties.js";import{fixTimeInfoFields as z}from"./support/fieldUtils.js";import{getSymbolWithColorSupport as K,createSimpleRenderersWithUniqueColors as Z}from"./support/subtypeGroupLayerUtils.js";import W from"./support/SubtypeSublayer.js";import X from"./support/TimeInfo.js";import{serviceSupportsSpatialReference as Y}from"./support/versionUtils.js";import ee from"../rest/support/Query.js";import{isNumber as te}from"../support/guards.js";import{addLayerUnsupportedError as re}from"../webdoc/support/unsupportedErrors.js";import{reader as se}from"../core/accessorSupport/decorators/reader.js";const ie="SubtypeGroupLayer";function oe(e,t){const r=[];for(const s of e){const e=new W;e.read(s,t),r.push(e)}return r}const ae=B();function ne(){return{name:"layerType",read:{enabled:!0},write:{enabled:!0,ignoreOrigin:!0,isRequired:!0}}}let ue=class extends(j(w(S(g(x(I(T(b(v(L(a(F(f(t(m))))))))))))))){constructor(...e){super(...e),this._sublayerLookup=new Map,this.fields=null,this.fieldsIndex=null,this.outFields=null,this.sublayers=new(r.ofType(W)),this.useUniqueColorsForSublayers=!0,this.supportedSourceTypes=new Set(["Feature Layer","Table"]),this.timeInfo=null,this.title="Layer",this.type="subtype-group",this._debouncedSaveOperations=n(async(e,t,r)=>{const{save:s,saveAs:i}=await(import("./save/featureLayerUtils.js"));switch(e){case 0:return s(this,t);case 1:return i(this,r,t)}}),this.addHandles(p(()=>this.sublayers,(e,t)=>this._handleSublayersChange(e,t),y))}destroy(){this.source?.destroy()}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){const t=null!=e?e.signal:null,r=this.loadFromPortal({supportedTypes:["Feature Service"]},e).catch(u).then(async()=>{if(!this.url)throw new s("subtype-grouplayer:missing-url-or-source","SubtypeGroupLayer must be created with either a url or a portal item");if(null==this.layerId)throw new s("subtype-grouplayer:missing-layerid","layerId is required for a SubtypeGroupLayer created with url");this._initLayerProperties(await this.createGraphicsSource(t))}).then(()=>O(this,"load",e));return this.addResolvingPromise(r),Promise.resolve(this)}get createQueryVersion(){return this.commitProperty("definitionExpression"),this.commitProperty("timeExtent"),this.commitProperty("timeOffset"),this.commitProperty("geometryType"),this.commitProperty("gdbVersion"),this.commitProperty("historicMoment"),this.commitProperty("returnZ"),this.commitProperty("capabilities"),this.commitProperty("returnM"),(this._get("createQueryVersion")??0)+1}get editingEnabled(){return this.loaded&&null!=this.capabilities&&this.capabilities.operations.supportsEditing&&this.userHasEditingPrivileges}get effectiveEditingEnabled(){return C(this)}get operationalLayerType(){return this.isTable?"SubtypeGroupTable":"SubtypeGroupLayer"}set source(e){this._get("source")!==e&&this._set("source",e)}readTitleFromService(e,{name:t}){return this.url?E(this.url,t):t}async addAttachment(e,t,r){const s=await P(this,e,t,ie,r);return this.lastEditsEventDate=new Date,s}async updateAttachment(e,t,r,s){const i=await U(this,e,t,r,ie,s);return this.lastEditsEventDate=new Date,i}async applyEdits(e,t){return G(this,e,t)}async createGraphicsSource(e){const{default:t}=await l(import("./graphics/sources/FeatureLayerSource.js"),e);return new t({layer:this,supportedSourceTypes:this.supportedSourceTypes}).load({signal:e})}createQuery(){const e=q(this),t=this.sublayers.map(e=>e.subtypeCode);return e.where=d(`${this.subtypeField} IN (${t.join(",")})`,this.definitionExpression),e}async deleteAttachments(e,t,r){const s=await D(this,e,t,ie,r);return this.lastEditsEventDate=new Date,s}async fetchRecomputedExtents(e){return M(this,e,ie)}findSublayerForFeature(e){const t=this.fieldsIndex.get(this.subtypeField),r=e.attributes[t.name];return this.findSublayerForSubtypeCode(r)}findSublayerForSubtypeCode(e){return this._sublayerLookup.get(e)}getFieldDomain(e,t){if(!t?.excludeImpliedDomains){const t=A(this,e);if(t)return t}const r=k(this,t?.feature);if(r){const t=r.domains?.[e];return"inherited"===t?.type?this._getLayerDomain(e):t}return this._getLayerDomain(e)}loadAll(){return i(this,e=>{e(this.sublayers)})}async queryAttachments(e,t){return R(this,e,t,ie)}async queryFeatures(e,t){const r=await this.load(),s=ee.from(e)??r.createQuery(),i=s.outFields??[];i.includes(this.subtypeField)||(i.push(this.subtypeField),s.outFields=i);const o=await r.source.queryFeatures(s,t);if(o?.features)for(const a of o.features){const e=this.findSublayerForFeature(a);a.origin=e?.graphicOrigin,a.layer=a.sourceLayer=this.findSublayerForFeature(a)}return o}async queryObjectIds(e,t){return(await N(this,e,t,ie)).filter(te)}async queryFeatureCount(e,t){return Q(this,e,t,ie)}async queryExtent(e,t){return $(this,e,t,ie)}async queryRelatedFeatures(e,t){return H(this,e,t,ie)}async queryRelatedFeaturesCount(e,t){return J(this,e,t,ie)}async save(e){return this._debouncedSaveOperations(0,e)}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}write(e,t){const{origin:r,layerContainerType:i,messages:o}=t;if(this.isTable){if("web-scene"===r||"web-map"===r&&"tables"!==i)return re(t,this,"a table source cannot be written to web scenes and web maps"),null}else if(this.loaded&&"web-map"===r&&"tables"===i)return re(t,this,"a non-table source cannot be written to tables in web maps"),null;return this.sublayers?.length?super.write(e,t):(o?.push(new s("web-document-write:invalid-property",`Layer (${this.title}, ${this.id}) of type '${this.declaredClass}' has invalid value for 'sublayers' property. 'sublayers' collection should contain at least one sublayer`,{layer:this})),null)}serviceSupportsSpatialReference(e){return!!this.loaded&&Y(this,e)}async getFeatureTitle(e,t){const r=this.findSublayerForFeature(e);return r?await r.getFeatureTitle(e,t):this._getFeatureTitleForUnknownSublayer(e)}async getFeatureTitles(e,t){const r=new Map,s=new Map,i=[],a=[s];if(e.forEach(e=>{const a=this.findSublayerForFeature(e);if(a)o(r,a,()=>[]).push(e);else{const r=e.getObjectId()??e.attributes[this.objectIdField];t?.fetchMissingFields?i.push(e):s.set(r,this._getFeatureTitleForUnknownSublayer(e))}}),i.length>0){const e=new Set(this.featureTitleFields);e.add(this.objectIdField),e.add(this.subtypeField);const t=await this.queryFeatures({outFields:[...e],returnGeometry:!1,objectIds:i.map(e=>e.getObjectId()??e.attributes[this.objectIdField])}),a=new Set;for(const i of t.features??[]){const e=i.getObjectId()??i.attributes[this.objectIdField];a.add(e);const t=this.findSublayerForFeature(i);t?o(r,t,()=>[]).push(i):s.set(e,this._getFeatureTitleForUnknownSublayer(i))}for(const r of i){const e=r.getObjectId()??r.attributes[this.objectIdField];a.has(e)||s.set(e,this._getFeatureTitleForUnknownSublayer(r))}}const n=await Promise.all(Array.from(r).map(([e,r])=>e.getFeatureTitles(r,t)));n.forEach(e=>a.push(e));const u=new Map(a.flatMap(e=>[...e]));return s.forEach((e,t)=>{u.set(t,e)}),u}get featureTitleFields(){const e=new Set;for(const t of this.sublayers){const r=t.featureTitleFields;for(const t of r)e.add(t)}return[...e]}_getLayerDomain(e){const t=this.fieldsIndex.get(e);return t?t.domain:null}_initLayerProperties(e){this._set("source",e);const{sourceJSON:t}=e;if(t&&(this.sourceJSON=t,this.read(t,{origin:"service",url:this.parsedUrl})),!this.subtypes?.length)throw new s("subtype-grouplayer:missing-subtypes","SubtypeGroupLayer must be created using a layer with subtypes");this._verifyFields(),z(this.timeInfo,this.fieldsIndex)}async hasDataChanged(){return V(this)}_verifyFields(){const e=this.parsedUrl?.path??"undefined";this.objectIdField||console.log("SubtypeGroupLayer: 'objectIdField' property is not defined (url: "+e+")"),this.isTable||-1!==e.search(/\/FeatureServer\//i)||this.fields?.some(e=>"geometry"===e.type)||console.log("SubtypeGroupLayer: unable to find field of type 'geometry' in the layer 'fields' list. If you are using a map service layer, features will not have geometry (url: "+e+")")}_handleSublayersChange(e,t){t&&(t.forEach(e=>{e.parent=null}),this.removeHandles("sublayers-owner"),this._sublayerLookup.clear()),e&&(e.forEach(e=>{e.parent=this,this._sublayerLookup.set(e.subtypeCode,e)}),this.addHandles([e.on("after-add",({item:e})=>{e.parent=this,this._sublayerLookup.set(e.subtypeCode,e)}),e.on("after-remove",({item:e})=>{e.parent=null,this._sublayerLookup.delete(e.subtypeCode)})],"sublayers-owner"))}_getFeatureTitleForUnknownSublayer(e){const{displayField:t,fieldsIndex:r,objectIdField:s}=this;if(t&&r.has(t))return e.attributes[r.get(t).name]??"";const i=e.getObjectId();return null!=i?i.toString():s&&r.has(s)?e.attributes[r.get(s).name]??"":""}};e([c({readOnly:!0})],ue.prototype,"createQueryVersion",null),e([c({readOnly:!0})],ue.prototype,"editingEnabled",null),e([c({readOnly:!0})],ue.prototype,"effectiveEditingEnabled",null),e([c({...ae.fields,readOnly:!0,json:{origins:{service:{read:!0}},read:!1}})],ue.prototype,"fields",void 0),e([c(ae.fieldsIndex)],ue.prototype,"fieldsIndex",void 0),e([c(_)],ue.prototype,"id",void 0),e([c({type:["show","hide","hide-children"],json:{origins:{"portal-item":{read:!1,write:!1}}}})],ue.prototype,"listMode",void 0),e([c({type:["SubtypeGroupLayer","SubtypeGroupTable"],json:{...ne(),origins:{"web-document":ne(),"portal-item":ne()}}})],ue.prototype,"operationalLayerType",null),e([c(ae.outFields)],ue.prototype,"outFields",void 0),e([c({clonable:!1})],ue.prototype,"source",null),e([c({type:r.ofType(W),json:{origins:{service:{read:{source:"subtypes",reader(e,t,s){let i=null;if(this.useUniqueColorsForSublayers){const r=K(t,s);i=r?Z(e.length,r):null}const o=e.map(({code:e},r)=>{const o=new W({subtypeCode:e});o.read(t,s);const a=i?.[r];return a&&o.read({drawingInfo:{renderer:a.toJSON()}},s),o});return new(r.ofType(W))(o)}}}},read:{source:["layers","tables"],reader(e,t,s){let i;return"SubtypeGroupLayer"===t.layerType&&t.layers?.length?i=oe(t.layers,s):"SubtypeGroupTable"===t.layerType&&t.tables?.length&&(i=oe(t.tables,s)),new(r.ofType(W))(i)}},write:{ignoreOrigin:!0,writer(e,t,r,s){const i=[];for(const o of e){const e=o.write({},s);i.push(e)}this.isTable?t.tables=i:t.layers=i}}}})],ue.prototype,"sublayers",void 0),e([c()],ue.prototype,"useUniqueColorsForSublayers",void 0),e([c({type:X})],ue.prototype,"timeInfo",void 0),e([c({json:{origins:{"portal-item":{write:{enabled:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}}}})],ue.prototype,"title",void 0),e([se("service","title",["name"])],ue.prototype,"readTitleFromService",null),e([c({json:{read:!1}})],ue.prototype,"type",void 0),e([c({clonable:!1,readOnly:!0})],ue.prototype,"featureTitleFields",null),ue=e([h("esri.layers.SubtypeGroupLayer")],ue);const le=ue;export{le as default};
2
+ import{__decorate as e}from"tslib";import{ClonableMixin as t}from"../core/Clonable.js";import r from"../core/Collection.js";import s from"../core/Error.js";import{loadAll as i}from"../core/loadAll.js";import{getOrCreateMapValue as o}from"../core/MapUtils.js";import{MultiOriginJSONSupportMixin as a}from"../core/MultiOriginJSONSupport.js";import{debounce as n,throwIfAbortError as u,whenOrAbort as l}from"../core/promiseUtils.js";import{watch as p,sync as y}from"../core/reactiveUtils.js";import{sqlAnd as d}from"../core/sql.js";import{property as c,subclass as h}from"../core/accessorSupport/decorators.js";import m from"./Layer.js";import{APIKeyMixin as b}from"./mixins/APIKeyMixin.js";import{ArcGISService as f}from"./mixins/ArcGISService.js";import{BlendLayer as g}from"./mixins/BlendLayer.js";import{CustomParametersMixin as F}from"./mixins/CustomParametersMixin.js";import{DisplayFilteredLayer as w}from"./mixins/DisplayFilteredLayer.js";import{EditBusLayer as S}from"./mixins/EditBusLayer.js";import{FeatureLayerBase as j}from"./mixins/FeatureLayerBase.js";import{FeatureLayerReload as v}from"./mixins/FeatureLayerReload.js";import{OperationalLayer as L}from"./mixins/OperationalLayer.js";import{PortalLayer as T}from"./mixins/PortalLayer.js";import{RefreshableLayer as I}from"./mixins/RefreshableLayer.js";import{ScaleRangeLayer as x}from"./mixins/ScaleRangeLayer.js";import{TemporalLayer as E}from"./mixins/TemporalLayer.js";import{titleFromUrlAndName as _}from"./support/arcgisLayerUrl.js";import{id as O}from"./support/commonProperties.js";import{ensureLayerCredential as P,computeEffectiveEditingEnabled as C,addAttachment as U,updateAttachment as G,applyEdits as q,createQuery as D,deleteAttachments as M,fetchRecomputedExtents as A,computeDomainFromSubtypes as k,getFeatureSubtype as R,queryAttachments as N,queryObjectIds as Q,queryFeatureCount as $,queryExtent as H,queryRelatedFeatures as J,queryRelatedFeaturesCount as V,hasDataChanged as B}from"./support/featureLayerUtils.js";import{defineFieldProperties as z}from"./support/fieldProperties.js";import{fixTimeInfoFields as K}from"./support/fieldUtils.js";import{getSymbolWithColorSupport as Z,createSimpleRenderersWithUniqueColors as W}from"./support/subtypeGroupLayerUtils.js";import X from"./support/SubtypeSublayer.js";import{serviceSupportsSpatialReference as Y}from"./support/versionUtils.js";import ee from"../rest/support/Query.js";import{isNumber as te}from"../support/guards.js";import{addLayerUnsupportedError as re}from"../webdoc/support/unsupportedErrors.js";import{reader as se}from"../core/accessorSupport/decorators/reader.js";const ie="SubtypeGroupLayer";function oe(e,t){const r=[];for(const s of e){const e=new X;e.read(s,t),r.push(e)}return r}const ae=z();function ne(){return{name:"layerType",read:{enabled:!0},write:{enabled:!0,ignoreOrigin:!0,isRequired:!0}}}let ue=class extends(v(j(w(S(g(E(x(I(f(L(T(a(F(b(t(m)))))))))))))))){constructor(...e){super(...e),this._sublayerLookup=new Map,this.fields=null,this.fieldsIndex=null,this.outFields=null,this.sublayers=new(r.ofType(X)),this.useUniqueColorsForSublayers=!0,this.supportedPortalItemTypes=["Feature Service"],this.supportedSourceTypes=new Set(["Feature Layer","Table"]),this.title="Layer",this.type="subtype-group",this._debouncedSaveOperations=n(async(e,t,r)=>{const{save:s,saveAs:i}=await(import("./save/featureLayerUtils.js"));switch(e){case 0:return s(this,t);case 1:return i(this,r,t)}}),this.addHandles(p(()=>this.sublayers,(e,t)=>this._handleSublayersChange(e,t),y))}destroy(){this.source?.destroy()}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){const t=null!=e?e.signal:null,r=this.loadFromPortal({supportedTypes:this.supportedPortalItemTypes},e).catch(u).then(async()=>{if(!this.url)throw new s("subtype-grouplayer:missing-url-or-source","SubtypeGroupLayer must be created with either a url or a portal item");if(null==this.layerId)throw new s("subtype-grouplayer:missing-layerid","layerId is required for a SubtypeGroupLayer created with url");this._initLayerProperties(await this.createGraphicsSource(t))}).then(()=>P(this,"load",e));return this.addResolvingPromise(r),Promise.resolve(this)}get createQueryVersion(){return this.commitProperty("definitionExpression"),this.commitProperty("timeExtent"),this.commitProperty("timeOffset"),this.commitProperty("geometryType"),this.commitProperty("gdbVersion"),this.commitProperty("historicMoment"),this.commitProperty("returnZ"),this.commitProperty("capabilities"),this.commitProperty("returnM"),(this._get("createQueryVersion")??0)+1}get editingEnabled(){return this.loaded&&null!=this.capabilities&&this.capabilities.operations.supportsEditing&&this.userHasEditingPrivileges}get effectiveEditingEnabled(){return C(this)}get operationalLayerType(){return this.isTable?"SubtypeGroupTable":"SubtypeGroupLayer"}set source(e){this._get("source")!==e&&this._set("source",e)}readTitleFromService(e,{name:t}){return this.url?_(this.url,t):t}async addAttachment(e,t,r){const s=await U(this,e,t,ie,r);return this.lastEditsEventDate=new Date,s}async updateAttachment(e,t,r,s){const i=await G(this,e,t,r,ie,s);return this.lastEditsEventDate=new Date,i}async applyEdits(e,t){return q(this,e,t)}async createGraphicsSource(e){const{default:t}=await l(import("./graphics/sources/FeatureLayerSource.js"),e);return new t({layer:this,supportedSourceTypes:this.supportedSourceTypes}).load({signal:e})}createQuery(){const e=D(this),t=this.sublayers.map(e=>e.subtypeCode);return e.where=d(`${this.subtypeField} IN (${t.join(",")})`,this.definitionExpression),e}async deleteAttachments(e,t,r){const s=await M(this,e,t,ie,r);return this.lastEditsEventDate=new Date,s}async fetchRecomputedExtents(e){return A(this,e,ie)}findSublayerForFeature(e){const t=this.fieldsIndex.get(this.subtypeField),r=e.attributes[t.name];return this.findSublayerForSubtypeCode(r)}findSublayerForSubtypeCode(e){return this._sublayerLookup.get(e)}getFieldDomain(e,t){if(!t?.excludeImpliedDomains){const t=k(this,e);if(t)return t}const r=R(this,t?.feature);if(r){const t=r.domains?.[e];return"inherited"===t?.type?this._getLayerDomain(e):t}return this._getLayerDomain(e)}loadAll(){return i(this,e=>{e(this.sublayers)})}async queryAttachments(e,t){return N(this,e,t,ie)}async queryFeatures(e,t){const r=await this.load(),s=ee.from(e)??r.createQuery(),i=s.outFields??[];i.includes(this.subtypeField)||(i.push(this.subtypeField),s.outFields=i);const o=await r.source.queryFeatures(s,t);if(o?.features)for(const a of o.features){const e=this.findSublayerForFeature(a);a.origin=e?.graphicOrigin,a.layer=a.sourceLayer=this.findSublayerForFeature(a)}return o}async queryObjectIds(e,t){return(await Q(this,e,t,ie)).filter(te)}async queryFeatureCount(e,t){return $(this,e,t,ie)}async queryExtent(e,t){return H(this,e,t,ie)}async queryRelatedFeatures(e,t){return J(this,e,t,ie)}async queryRelatedFeaturesCount(e,t){return V(this,e,t,ie)}async save(e){return this._debouncedSaveOperations(0,e)}async saveAs(e,t){return this._debouncedSaveOperations(1,t,e)}write(e,t){const{origin:r,layerContainerType:i,messages:o}=t;if(this.isTable){if("web-scene"===r||"web-map"===r&&"tables"!==i)return re(t,this,"a table source cannot be written to web scenes and web maps"),null}else if(this.loaded&&"web-map"===r&&"tables"===i)return re(t,this,"a non-table source cannot be written to tables in web maps"),null;return this.sublayers?.length?super.write(e,t):(o?.push(new s("web-document-write:invalid-property",`Layer (${this.title}, ${this.id}) of type '${this.declaredClass}' has invalid value for 'sublayers' property. 'sublayers' collection should contain at least one sublayer`,{layer:this})),null)}serviceSupportsSpatialReference(e){return!!this.loaded&&Y(this,e)}async getFeatureTitle(e,t){const r=this.findSublayerForFeature(e);return r?await r.getFeatureTitle(e,t):this._getFeatureTitleForUnknownSublayer(e)}async getFeatureTitles(e,t){const r=new Map,s=new Map,i=[],a=[s];if(e.forEach(e=>{const a=this.findSublayerForFeature(e);if(a)o(r,a,()=>[]).push(e);else{const r=e.getObjectId()??e.attributes[this.objectIdField];t?.fetchMissingFields?i.push(e):s.set(r,this._getFeatureTitleForUnknownSublayer(e))}}),i.length>0){const e=new Set(this.featureTitleFields);e.add(this.objectIdField),e.add(this.subtypeField);const t=await this.queryFeatures({outFields:[...e],returnGeometry:!1,objectIds:i.map(e=>e.getObjectId()??e.attributes[this.objectIdField])}),a=new Set;for(const i of t.features??[]){const e=i.getObjectId()??i.attributes[this.objectIdField];a.add(e);const t=this.findSublayerForFeature(i);t?o(r,t,()=>[]).push(i):s.set(e,this._getFeatureTitleForUnknownSublayer(i))}for(const r of i){const e=r.getObjectId()??r.attributes[this.objectIdField];a.has(e)||s.set(e,this._getFeatureTitleForUnknownSublayer(r))}}const n=await Promise.all(Array.from(r).map(([e,r])=>e.getFeatureTitles(r,t)));n.forEach(e=>a.push(e));const u=new Map(a.flatMap(e=>[...e]));return s.forEach((e,t)=>{u.set(t,e)}),u}get featureTitleFields(){const e=new Set;for(const t of this.sublayers){const r=t.featureTitleFields;for(const t of r)e.add(t)}return[...e]}_getLayerDomain(e){const t=this.fieldsIndex.get(e);return t?t.domain:null}_initLayerProperties(e){this._set("source",e);const{sourceJSON:t}=e;if(t&&(this.sourceJSON=t,this.read(t,{origin:"service",url:this.parsedUrl})),!this.subtypes?.length)throw new s("subtype-grouplayer:missing-subtypes","SubtypeGroupLayer must be created using a layer with subtypes");this._verifyFields(),K(this.timeInfo,this.fieldsIndex)}async reloadFromService(e){const t=this.source;await t.reload({signal:e}),this._initLayerProperties(t)}async hasDataChanged(){return B(this)}_verifyFields(){const e=this.parsedUrl?.path??"undefined";this.objectIdField||console.log("SubtypeGroupLayer: 'objectIdField' property is not defined (url: "+e+")"),this.isTable||-1!==e.search(/\/FeatureServer\//i)||this.fields?.some(e=>"geometry"===e.type)||console.log("SubtypeGroupLayer: unable to find field of type 'geometry' in the layer 'fields' list. If you are using a map service layer, features will not have geometry (url: "+e+")")}_handleSublayersChange(e,t){t&&(t.forEach(e=>{e.parent=null}),this.removeHandles("sublayers-owner"),this._sublayerLookup.clear()),e&&(e.forEach(e=>{e.parent=this,this._sublayerLookup.set(e.subtypeCode,e)}),this.addHandles([e.on("after-add",({item:e})=>{e.parent=this,this._sublayerLookup.set(e.subtypeCode,e)}),e.on("after-remove",({item:e})=>{e.parent=null,this._sublayerLookup.delete(e.subtypeCode)})],"sublayers-owner"))}_getFeatureTitleForUnknownSublayer(e){const{displayField:t,fieldsIndex:r,objectIdField:s}=this;if(t&&r.has(t))return e.attributes[r.get(t).name]??"";const i=e.getObjectId();return null!=i?i.toString():s&&r.has(s)?e.attributes[r.get(s).name]??"":""}};e([c({readOnly:!0})],ue.prototype,"createQueryVersion",null),e([c({readOnly:!0})],ue.prototype,"editingEnabled",null),e([c({readOnly:!0})],ue.prototype,"effectiveEditingEnabled",null),e([c({...ae.fields,readOnly:!0,json:{origins:{service:{read:!0}},read:!1}})],ue.prototype,"fields",void 0),e([c(ae.fieldsIndex)],ue.prototype,"fieldsIndex",void 0),e([c(O)],ue.prototype,"id",void 0),e([c({type:["show","hide","hide-children"],json:{origins:{"portal-item":{read:!1,write:!1}}}})],ue.prototype,"listMode",void 0),e([c({type:["SubtypeGroupLayer","SubtypeGroupTable"],json:{...ne(),origins:{"web-document":ne(),"portal-item":ne()}}})],ue.prototype,"operationalLayerType",null),e([c(ae.outFields)],ue.prototype,"outFields",void 0),e([c({clonable:!1})],ue.prototype,"source",null),e([c({type:r.ofType(X),json:{origins:{service:{read:{source:"subtypes",reader(e,t,s){let i=null;if(this.useUniqueColorsForSublayers){const r=Z(t,s);i=r?W(e.length,r):null}const o=e.map(({code:e},r)=>{const o=new X({subtypeCode:e});o.read(t,s);const a=i?.[r];return a&&o.read({drawingInfo:{renderer:a.toJSON()}},s),o});return new(r.ofType(X))(o)}}}},read:{source:["layers","tables"],reader(e,t,s){let i;return"SubtypeGroupLayer"===t.layerType&&t.layers?.length?i=oe(t.layers,s):"SubtypeGroupTable"===t.layerType&&t.tables?.length&&(i=oe(t.tables,s)),new(r.ofType(X))(i)}},write:{ignoreOrigin:!0,writer(e,t,r,s){const i=[];for(const o of e){const e=o.write({},s);i.push(e)}this.isTable?t.tables=i:t.layers=i}}}})],ue.prototype,"sublayers",void 0),e([c()],ue.prototype,"useUniqueColorsForSublayers",void 0),e([c({json:{origins:{"portal-item":{write:{enabled:!0,ignoreOrigin:!0,writerEnsuresNonNull:!0}}}}})],ue.prototype,"title",void 0),e([se("service","title",["name"])],ue.prototype,"readTitleFromService",null),e([c({json:{read:!1}})],ue.prototype,"type",void 0),e([c({clonable:!1,readOnly:!0})],ue.prototype,"featureTitleFields",null),ue=e([h("esri.layers.SubtypeGroupLayer")],ue);const le=ue;export{le as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../config.js";import r from"../../../request.js";import{isSome as s,remove as a}from"../../../core/arrayUtils.js";import i from"../../../core/Error.js";import has from"../../../core/has.js";import{JSONMap as n}from"../../../core/jsonMap.js";import{Loadable as o}from"../../../core/Loadable.js";import u from"../../../core/Logger.js";import{setDeepValue as l}from"../../../core/object.js";import{debounce as c,after as d,throwIfAbortError as p}from"../../../core/promiseUtils.js";import{watch as y}from"../../../core/reactiveUtils.js";import{join as h}from"../../../core/urlUtils.js";import{generateBracedUUID as m}from"../../../core/uuid.js";import{property as f,subclass as g}from"../../../core/accessorSupport/decorators.js";import q from"../../../geometry/Extent.js";import w from"../../../geometry/SpatialReference.js";import S from"../../../geometry/support/MeshGeoreferencedVertexSpace.js";import{isRelativeVertexSpace as E}from"../../../geometry/support/meshVertexSpaceUtils.js";import{isOriginalExternal as O}from"../../../geometry/support/meshUtils/External.js";import{createFeatureEditResult as _,getFeatureJSON as b,getFeatureIds as R,getAttachmentEditsJSON as F,isProtectedOrPrivateVersionError as A,unpackEditResultData as I,createEditedFeatures as v}from"../applyEditsUtils.js";import{createDrawingInfo as x}from"./support/clientSideDefaults.js";import j from"./support/QueryTask.js";import{isHostedAgolService as T}from"../../support/arcgisLayerUrl.js";import{ensureLayerCredential as M}from"../../support/featureLayerUtils.js";import{getAssetMapTable as N}from"../../support/infoFor3D.js";import{executeQueryJSON as U}from"../../../rest/query/executeQueryJSON.js";import{unapplyEditsZUnitScaling as C}from"../../../rest/query/operations/editsZScale.js";import D from"../../../rest/support/Query.js";import J from"../../../time/TimeExtent.js";import{isSafeToEditVersion as L,isVersionInEditSession as k,isHistoricVersion as Q,currentSessionId as P}from"../../../versionManagement/support/versionManagementUtils.js";const V=new n({originalAndCurrentFeatures:"original-and-current-features",none:"none"}),$=new n({Started:"published",Publishing:"publishing",Stopped:"unavailable"});let B=class extends o{constructor(e){super(e),this.type="feature-layer",this.supportedSourceTypes=new Set(["Feature Layer","Oriented Imagery Layer","Table","Catalog Layer","Annotation Layer","Dimension Layer"]),this.refresh=c(async()=>{await this.load();const e=this.sourceJSON.editingInfo?.lastEditDate;if(null==e)return{dataChanged:!0,updates:{}};try{await this._fetchService(null)}catch{return{dataChanged:!0,updates:{}}}const t=e!==this.sourceJSON.editingInfo?.lastEditDate;return{dataChanged:t,updates:t?{editingInfo:this.sourceJSON.editingInfo,extent:this.sourceJSON.extent}:null}}),this._ongoingAssetUploads=new Map}load(e){const t=this.layer.sourceJSON,r=this._fetchService(t,{...e}).then(()=>this.layer.setUserPrivileges(this.sourceJSON.serviceItemId,e)).then(()=>this._ensureLatestMetadata(e));return this.addResolvingPromise(r),Promise.resolve(this)}initialize(){this.addHandles([y(()=>{const e=this.layer;return e&&"lastEditsEventDate"in e?e.lastEditsEventDate:null},e=>this._handleLastEditsEventChange(e))])}destroy(){this._removeEditInterceptor()}get queryTask(){const{capabilities:e,parsedUrl:t,gdbVersion:r,spatialReference:s,fieldsIndex:a,uniqueIdFields:i}=this.layer,n="infoFor3D"in this.layer?this.layer.infoFor3D:null,o="dynamicDataSource"in this.layer?this.layer.dynamicDataSource:null,u=has("featurelayer-pbf")&&e?.query.supportsFormatPBF&&null==n,l=u&&e?.query.supportsFormatPBFWithCurves,c=e?.operations?.supportsQueryAttachments??!1,d=e?.query?.relativeTimeBinWindow??0,p=t.path;return new j({dynamicDataSource:o,fieldsIndex:a,gdbVersion:r,infoFor3D:n,pbfSupported:u,pbfSupportedWithCurves:l,queryAttachmentsSupported:c,relativeTimeBinWindow:d,sourceSpatialReference:s,uniqueIdFields:i,url:p})}async addAttachment(e,t,s){await this.load();const{layer:a}=this;await M(a,"editing");const i=e.attributes[a.objectIdField],n=a.parsedUrl.path+"/"+i+"/addAttachment",o=this._getLayerRequestOptions({query:s}),u=this._getFormDataForAttachment(t,o.query);try{const e=await r(n,{body:u});return _(e.data.addAttachmentResult)}catch(l){throw this._createAttachmentErrorResult(i,l)}}async updateAttachment(e,t,s,a){await this.load();const{layer:i}=this;await M(i,"editing");const n=e.attributes[i.objectIdField],o=i.parsedUrl.path+"/"+n+"/updateAttachment",u=this._getLayerRequestOptions({query:{attachmentId:t,...a}}),l=this._getFormDataForAttachment(s,u.query);try{const e=await r(o,{body:l});return _(e.data.updateAttachmentResult)}catch(c){throw this._createAttachmentErrorResult(n,c)}}async applyEdits(e,t){await this.load();const{layer:a}=this;await M(a,"editing");const n="infoFor3D"in a?a.infoFor3D:null,o=null!=n,u=o||(t?.globalIdUsed??!1),l=o?await this._uploadMeshesAndGetAssetMapEditsJSON(e):null,c=e.addFeatures?.map(e=>b(this.layer,e,n))??[],d=(await Promise.all(c)).filter(s),p=e.updateFeatures?.map(e=>b(this.layer,e,n))??[],y=(await Promise.all(p)).filter(s),h=R(this.layer,e.deleteFeatures,u);C(d,y,a.spatialReference);const m=await F(this.layer,e),f=a.capabilities.editing.supportsAsyncApplyEdits&&o,g=t?.gdbVersion||a.gdbVersion,q={gdbVersion:g,rollbackOnFailure:t?.rollbackOnFailureEnabled,useGlobalIds:u,returnEditMoment:t?.returnEditMoment,trueCurveClient:t?.editsRespectTrueCurves,usePreviousEditMoment:t?.usePreviousEditMoment,async:f};await L(this.layer.url,g,!0);const w=k(this.layer.url,g||null);if(await Q(a.url,g,a.historicMoment))throw new i("feature-layer-source:historic-version","Editing a historic version is not allowed");t?.returnServiceEditsOption?(q.edits=JSON.stringify([{id:a.layerId,adds:d.length?d:null,updates:y.length?y:null,deletes:h.length?h:null,attachments:m,assetMaps:l}]),q.returnServiceEditsOption=V.toJSON(t?.returnServiceEditsOption),q.returnServiceEditsInSourceSR=t?.returnServiceEditsInSourceSR):(q.adds=d.length?JSON.stringify(d):null,q.updates=y.length?JSON.stringify(y):null,q.deletes=h.length?u?JSON.stringify(h):h.join(","):null,q.attachments=m&&JSON.stringify(m),q.assetMaps=null!=l?JSON.stringify(l):void 0);const S=this._getLayerRequestOptions({method:"post",query:q});w&&(S.authMode="immediate",S.query.returnEditMoment=!0,S.query.sessionId=P);const E=t?.returnServiceEditsOption?a.url:a.parsedUrl.path;let O;try{O=f?await this._asyncApplyEdits(E+"/applyEdits",S):await r(E+"/applyEdits",S)}catch(_){if(!A(_))throw _;S.authMode="immediate",O=f?await this._asyncApplyEdits(E+"/applyEdits",S):await r(E+"/applyEdits",S)}return this._createEditsResult(O)}async deleteAttachments(e,t,s){await this.load();const{layer:a}=this;await M(a,"editing");const i=e.attributes[a.objectIdField],n=a.parsedUrl.path+"/"+i+"/deleteAttachments";try{return(await r(n,this._getLayerRequestOptions({query:{attachmentIds:t.join(","),...s},method:"post"}))).data.deleteAttachmentResults.map(_)}catch(o){throw this._createAttachmentErrorResult(i,o)}}fetchRecomputedExtents(e={}){const t=e.signal;return this.load({signal:t}).then(async()=>{const t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:s,url:a}=this.layer,{data:i}=await r(`${a}/${s}`,t),{id:n,extent:o,fullExtent:u,timeExtent:l}=i,c=o||u;return{id:n,fullExtent:c&&q.fromJSON(c),timeExtent:l&&J.fromJSON({start:l[0],end:l[1]})}})}async queryAttachments(e,t={}){await this.load();const r=this._getLayerRequestOptions(t);return this.queryTask.executeAttachmentQuery(e,r)}async queryFeatures(e,t){await this.load();const r=await this.queryTask.execute(e,{...t,query:this._createRequestQueryOptions(t)});if(e.outStatistics?.length&&r.features.length){const t=new Map;if(r.features.forEach(r=>{const s=r.attributes;e.outStatistics?.forEach(({outStatisticFieldName:e})=>{if(e){const r=e.toLowerCase();r&&r in s&&e!==r&&(s[e]=s[r],delete s[r],t.set(r,e))}})}),null!=r.fields)for(const e of r.fields){const r=t.get(e.name.toLowerCase());null!=r&&(e.name=r)}}return r}async queryFeaturesJSON(e,t){return await this.load(),this.queryTask.executeJSON(e,{...t,query:this._createRequestQueryOptions(t)})}async queryObjectIds(e,t){return await this.load(),this.queryTask.executeForIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryFeatureCount(e,t){return await this.load(),this.queryTask.executeForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryExtent(e,t){return await this.load(),this.queryTask.executeForExtent(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeatures(e,t){return await this.load(),this.queryTask.executeRelationshipQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeaturesCount(e,t){return await this.load(),this.queryTask.executeRelationshipQueryForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryPivot(e,t){return await this.load(),this.queryTask.executePivotQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopFeatures(e,t){return await this.load(),this.queryTask.executeTopFeaturesQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryAttributeBins(e,t){return await this.load(),this.queryTask.executeAttributeBinsQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopObjectIds(e,t){return await this.load(),this.queryTask.executeForTopIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopExtents(e,t){return await this.load(),this.queryTask.executeForTopExtents(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopCount(e,t){return await this.load(),this.queryTask.executeForTopCount(e,{...t,query:this._createRequestQueryOptions(t)})}async fetchPublishingStatus(){if(!T(this.layer.url))return"unavailable";const e=h(this.layer.url,"status"),t=await r(e,{query:{f:"json"}});return $.fromJSON(t.data.status)}async uploadAssets(e,t){const{uploadAssets:r}=await(import("./support/uploadAssets.js"));return r(e,{layer:this.layer,ongoingUploads:this._ongoingAssetUploads},t)}_handleLastEditsEventChange(e){const t=this.layer;if(null==e||!("capabilities"in t)||!("effectiveCapabilities"in t))return;if(!(!t.capabilities?.operations?.supportsEditing&&t.effectiveCapabilities?.operations?.supportsEditing))return;let r=t.url;if(null==r)return;"layerId"in t&&(r=h(r,t.layerId.toString()));this._getOrCreateEditInterceptor(r).before=t=>{const r=t.requestOptions.method??"auto";if("auto"===r||"head"===r){const r=t.requestOptions.query??{};r._ts=e.getTime(),t.requestOptions.query=r}}}_getOrCreateEditInterceptor(e){return null==this._editInterceptor&&(this._editInterceptor={urls:e},t.request.internalInterceptors.push(this._editInterceptor)),this._editInterceptor}_removeEditInterceptor(){null!=this._editInterceptor&&(a(t.request.internalInterceptors,this._editInterceptor),this._editInterceptor=null)}async _asyncApplyEdits(e,t){const s=(await r(e,t)).data.statusUrl;for(;;){const e=(await r(s,{query:{f:"json"},responseType:"json"})).data;switch(e.status){case"Completed":return r(e.resultUrl,{query:{f:"json"},responseType:"json"});case"CompletedWithErrors":throw new i("async-applyEdits-failed","asynchronous applyEdits call failed.");case"Failed ImportChanges":case"InProgress":case"Pending":case"ExportAttachments":case"ExportChanges":case"ExportingData":case"ExportingSnapshot":case"ImportAttachments":case"ProvisioningReplica":case"UnRegisteringReplica":break;default:throw new i("async-applyEdits-failed","asynchronous applyEdits call failed (undefined response status)")}await d(G)}}_createRequestQueryOptions(e){const t={...this.layer.customParameters,token:this.layer.apiKey,...e?.query};return this.layer.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t}async _fetchService(e,t){if(!e){const s={};has("featurelayer-advanced-symbols")&&(s.returnAdvancedSymbols=!0),t?.cacheBust&&(s._ts=Date.now());const{data:a}=await r(this.layer.parsedUrl.path,this._getLayerRequestOptions({query:s,signal:t?.signal}));e=a}this.layer.applyPreferredHost(e),this.sourceJSON=await this._patchServiceJSON(e,t?.signal);const s=e.type;if(!this.supportedSourceTypes.has(s))throw new i("feature-layer-source:unsupported-type",`Source type "${s}" is not supported`)}async _patchServiceJSON(e,t){if("Table"!==e.type&&e.geometryType&&!e?.drawingInfo?.renderer&&!e.defaultSymbol){const t=x(e.geometryType).renderer;l("drawingInfo.renderer",t,e)}if("esriGeometryMultiPatch"===e.geometryType&&e.infoFor3D&&(e.geometryType="mesh"),null==e.extent)try{const{data:s}=await r(this.layer.url,this._getLayerRequestOptions({signal:t}));s.spatialReference&&(e.extent={xmin:0,ymin:0,xmax:0,ymax:0,spatialReference:s.spatialReference})}catch(s){p(s)}return e}async _ensureLatestMetadata(e){if(this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0)return this._fetchService(null,{...e,cacheBust:!0})}async _uploadMeshesAndGetAssetMapEditsJSON(e){const{addAssetFeatures:t}=e;if(!t?.length)return null;if(await this._areAllAssetsAlreadyMapped(t))return null;const r=e.addFeatures.filter(e=>e.geometry);if(t.length!==r.length+e.updateFeatures.length)throw new i("feature-layer-source:unsupported-mesh-edits","Mixing attribute only edits with mesh geometry edits is not currently supported");const s=new Array,a=new Map;for(const i of t){const{geometry:e}=i,{vertexSpace:t}=e;if(E(t))s.push(e);else{const t=e.origin,{convertMeshVertexSpace:r}=await(import("../../../geometry/support/meshUtils/convertMeshVertexSpace.js")),n=await r(e,new S({origin:[t.x,t.y,t.z??0]}));a.set(n,e),i.geometry=n,s.push(n)}}await this.uploadAssets(s);for(const[i,n]of a)n.addExternalSources(i.metadata.externalSources.items);return{adds:this._getAssetMapEditsJSON(t),updates:[],deletes:[]}}_getAssetMapEditsJSON(e){const t=new Array,r=this.layer.globalIdField,s=this.layer.parsedUrl;for(const a of e){const e=a.geometry,{metadata:i}=e,n=i.getExternalSourcesOnService(s),o=a.getAttribute(r);if(0===n.length){u.getLogger(this).error(`Skipping feature ${o}. The mesh it is associated with has not been uploaded to the service and cannot be mapped to it.`);continue}const{source:l}=n.find(O)??n[0];for(const r of l.assets)1===r.parts.length?t.push({globalId:m(),parentGlobalId:o,assetName:r.assetName,assetHash:r.parts[0].partHash,flags:[]}):u.getLogger(this).error(`Skipping asset ${r.assetName}. It does not have exactly one part, so we cannot map it to a feature.`)}return t}_createEditsResult(e){const t=e.data,{layerId:r}=this.layer,s=[];let a=null;if(Array.isArray(t))for(const n of t)s.push({id:n.id,editedFeatures:n.editedFeatures}),n.id===r&&(a={addResults:n.addResults??[],updateResults:n.updateResults??[],deleteResults:n.deleteResults??[],attachments:n.attachments,editMoment:n.editMoment});else a=t;const i=I(a);if(s.length>0){i.editedFeatureResults=[];for(const e of s){const{editedFeatures:t}=e,r=t?.spatialReference?new w(t.spatialReference):null;i.editedFeatureResults.push({layerId:e.id,editedFeatures:v(t,r)})}}return i}_createAttachmentErrorResult(e,t){const r=t.details.messages?.[0]||t.message,s=t.details.httpStatus||t.details.messageCode;return{objectId:e,globalId:null,error:new i("feature-layer-source:attachment-failure",r,{code:s})}}_getFormDataForAttachment(e,t){const r=e instanceof FormData?e:e&&e.elements?new FormData(e):null;if(r)for(const s in t){const e=t[s];null!=e&&(r.set?r.set(s,e):r.append(s,e))}return r}_getLayerRequestOptions(e={}){const{layer:t,layer:{parsedUrl:r,gdbVersion:s}}=this;return{...e,query:{gdbVersion:s,layer:"dynamicDataSource"in t&&t.dynamicDataSource?JSON.stringify({source:t.dynamicDataSource}):void 0,...r.query,f:"json",...this._createRequestQueryOptions(e)},responseType:"json"}}async _areAllAssetsAlreadyMapped(e){const{layer:t}=this,{globalIdField:r,parsedUrl:a}=t,i="infoFor3D"in t?t.infoFor3D:null;if(null==i||null==r)return!1;const n=N(i);if(null==n)return!1;const o=h(a.path,`../${n.id}`),u=new Array;for(const s of e){if(!(s.geometry.metadata.getExternalSourcesOnService(a).length>0))return!1;u.push(s)}const l=u.map(e=>e.getAttribute(r)).filter(s);if(0===l.length)return!1;const{assetMapFieldRoles:{parentGlobalId:c,assetHash:d}}=i,p=new D({where:`${c} IN (${l.map(e=>`'${e}'`)})`,outFields:[d,c],returnGeometry:!1}),y=await U(o,p),{features:m}=y;return 0!==m.length&&!u.some(e=>{const t=e.getAttribute(r);if(!t)return!0;const{metadata:s}=e.geometry,i=m.filter(e=>e.getAttribute(c)===t);if(0===i.length)return!0;const n=i.map(e=>e.getAttribute(d));return s.getExternalSourcesOnService(a).flatMap(({source:e})=>e.assets.flatMap(e=>e.parts.map(e=>e.partHash))).some(e=>n.every(t=>e!==t))})}};e([f()],B.prototype,"type",void 0),e([f({constructOnly:!0})],B.prototype,"layer",void 0),e([f({constructOnly:!0})],B.prototype,"supportedSourceTypes",void 0),e([f({readOnly:!0})],B.prototype,"queryTask",null),B=e([g("esri.layers.graphics.sources.FeatureLayerSource")],B);const G=1e3;export{B as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../config.js";import r from"../../../request.js";import{isSome as s,remove as a}from"../../../core/arrayUtils.js";import i from"../../../core/Error.js";import has from"../../../core/has.js";import{JSONMap as n}from"../../../core/jsonMap.js";import{Loadable as o}from"../../../core/Loadable.js";import u from"../../../core/Logger.js";import{setDeepValue as l}from"../../../core/object.js";import{debounce as c,after as d,throwIfAbortError as p}from"../../../core/promiseUtils.js";import{watch as y}from"../../../core/reactiveUtils.js";import{join as h}from"../../../core/urlUtils.js";import{generateBracedUUID as m}from"../../../core/uuid.js";import{property as f,subclass as g}from"../../../core/accessorSupport/decorators.js";import q from"../../../geometry/Extent.js";import w from"../../../geometry/SpatialReference.js";import S from"../../../geometry/support/MeshGeoreferencedVertexSpace.js";import{isRelativeVertexSpace as E}from"../../../geometry/support/meshVertexSpaceUtils.js";import{isOriginalExternal as O}from"../../../geometry/support/meshUtils/External.js";import{createFeatureEditResult as _,getFeatureJSON as b,getFeatureIds as R,getAttachmentEditsJSON as A,isProtectedOrPrivateVersionError as F,unpackEditResultData as v,createEditedFeatures as I}from"../applyEditsUtils.js";import{createDrawingInfo as x}from"./support/clientSideDefaults.js";import j from"./support/QueryTask.js";import{isHostedAgolService as T}from"../../support/arcgisLayerUrl.js";import{ensureLayerCredential as M}from"../../support/featureLayerUtils.js";import{getAssetMapTable as N}from"../../support/infoFor3D.js";import{executeQueryJSON as U}from"../../../rest/query/executeQueryJSON.js";import{unapplyEditsZUnitScaling as C}from"../../../rest/query/operations/editsZScale.js";import J from"../../../rest/support/Query.js";import D from"../../../time/TimeExtent.js";import{isSafeToEditVersion as L,isVersionInEditSession as k,isHistoricVersion as Q,currentSessionId as P}from"../../../versionManagement/support/versionManagementUtils.js";const V=new n({originalAndCurrentFeatures:"original-and-current-features",none:"none"}),B=new n({Started:"published",Publishing:"publishing",Stopped:"unavailable"});let $=class extends o{constructor(e){super(e),this.type="feature-layer",this.supportedSourceTypes=new Set(["Feature Layer","Oriented Imagery Layer","Table","Catalog Layer","Annotation Layer","Dimension Layer"]),this.refresh=c(async()=>{await this.load();const e=this.sourceJSON.editingInfo?.lastEditDate;if(null==e)return{dataChanged:!0,updates:{}};try{await this._fetchService(null)}catch{return{dataChanged:!0,updates:{}}}const t=e!==this.sourceJSON.editingInfo?.lastEditDate;return{dataChanged:t,updates:t?{editingInfo:this.sourceJSON.editingInfo,extent:this.sourceJSON.extent}:null}}),this._ongoingAssetUploads=new Map}load(e){const t=this.layer.sourceJSON,r=this._fetchService(t,{...e}).then(()=>this.layer.setUserPrivileges(this.sourceJSON.serviceItemId,e)).then(()=>this._ensureLatestMetadata(e));return this.addResolvingPromise(r),Promise.resolve(this)}async reload(e){const t=this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0;await this._fetchService(null,{...e,cacheBust:t})}initialize(){this.addHandles([y(()=>{const e=this.layer;return e&&"lastEditsEventDate"in e?e.lastEditsEventDate:null},e=>this._handleLastEditsEventChange(e))])}destroy(){this._removeEditInterceptor()}get queryTask(){const{capabilities:e,parsedUrl:t,gdbVersion:r,spatialReference:s,fieldsIndex:a,uniqueIdFields:i}=this.layer,n="infoFor3D"in this.layer?this.layer.infoFor3D:null,o="dynamicDataSource"in this.layer?this.layer.dynamicDataSource:null,u=has("featurelayer-pbf")&&e?.query.supportsFormatPBF&&null==n,l=u&&e?.query.supportsFormatPBFWithCurves,c=e?.operations?.supportsQueryAttachments??!1,d=e?.query?.relativeTimeBinWindow??0,p=t.path;return new j({dynamicDataSource:o,fieldsIndex:a,gdbVersion:r,infoFor3D:n,pbfSupported:u,pbfSupportedWithCurves:l,queryAttachmentsSupported:c,relativeTimeBinWindow:d,sourceSpatialReference:s,uniqueIdFields:i,url:p})}async addAttachment(e,t,s){await this.load();const{layer:a}=this;await M(a,"editing");const i=e.attributes[a.objectIdField],n=a.parsedUrl.path+"/"+i+"/addAttachment",o=this._getLayerRequestOptions({query:s}),u=this._getFormDataForAttachment(t,o.query);try{const e=await r(n,{body:u});return _(e.data.addAttachmentResult)}catch(l){throw this._createAttachmentErrorResult(i,l)}}async updateAttachment(e,t,s,a){await this.load();const{layer:i}=this;await M(i,"editing");const n=e.attributes[i.objectIdField],o=i.parsedUrl.path+"/"+n+"/updateAttachment",u=this._getLayerRequestOptions({query:{attachmentId:t,...a}}),l=this._getFormDataForAttachment(s,u.query);try{const e=await r(o,{body:l});return _(e.data.updateAttachmentResult)}catch(c){throw this._createAttachmentErrorResult(n,c)}}async applyEdits(e,t){await this.load();const{layer:a}=this;await M(a,"editing");const n="infoFor3D"in a?a.infoFor3D:null,o=null!=n,u=o||(t?.globalIdUsed??!1),l=o?await this._uploadMeshesAndGetAssetMapEditsJSON(e):null,c=e.addFeatures?.map(e=>b(this.layer,e,n))??[],d=(await Promise.all(c)).filter(s),p=e.updateFeatures?.map(e=>b(this.layer,e,n))??[],y=(await Promise.all(p)).filter(s),h=R(this.layer,e.deleteFeatures,u);C(d,y,a.spatialReference);const m=await A(this.layer,e),f=a.capabilities.editing.supportsAsyncApplyEdits&&o,g=t?.gdbVersion||a.gdbVersion,q={gdbVersion:g,rollbackOnFailure:t?.rollbackOnFailureEnabled,useGlobalIds:u,returnEditMoment:t?.returnEditMoment,trueCurveClient:t?.editsRespectTrueCurves,usePreviousEditMoment:t?.usePreviousEditMoment,async:f};await L(this.layer.url,g,!0);const w=k(this.layer.url,g||null);if(await Q(a.url,g,a.historicMoment))throw new i("feature-layer-source:historic-version","Editing a historic version is not allowed");t?.returnServiceEditsOption?(q.edits=JSON.stringify([{id:a.layerId,adds:d.length?d:null,updates:y.length?y:null,deletes:h.length?h:null,attachments:m,assetMaps:l}]),q.returnServiceEditsOption=V.toJSON(t?.returnServiceEditsOption),q.returnServiceEditsInSourceSR=t?.returnServiceEditsInSourceSR):(q.adds=d.length?JSON.stringify(d):null,q.updates=y.length?JSON.stringify(y):null,q.deletes=h.length?u?JSON.stringify(h):h.join(","):null,q.attachments=m&&JSON.stringify(m),q.assetMaps=null!=l?JSON.stringify(l):void 0);const S=this._getLayerRequestOptions({method:"post",query:q});w&&(S.authMode="immediate",S.query.returnEditMoment=!0,S.query.sessionId=P);const E=t?.returnServiceEditsOption?a.url:a.parsedUrl.path;let O;try{O=f?await this._asyncApplyEdits(E+"/applyEdits",S):await r(E+"/applyEdits",S)}catch(_){if(!F(_))throw _;S.authMode="immediate",O=f?await this._asyncApplyEdits(E+"/applyEdits",S):await r(E+"/applyEdits",S)}return this._createEditsResult(O)}async deleteAttachments(e,t,s){await this.load();const{layer:a}=this;await M(a,"editing");const i=e.attributes[a.objectIdField],n=a.parsedUrl.path+"/"+i+"/deleteAttachments";try{return(await r(n,this._getLayerRequestOptions({query:{attachmentIds:t.join(","),...s},method:"post"}))).data.deleteAttachmentResults.map(_)}catch(o){throw this._createAttachmentErrorResult(i,o)}}fetchRecomputedExtents(e={}){const t=e.signal;return this.load({signal:t}).then(async()=>{const t=this._getLayerRequestOptions({...e,query:{returnUpdates:!0}}),{layerId:s,url:a}=this.layer,{data:i}=await r(`${a}/${s}`,t),{id:n,extent:o,fullExtent:u,timeExtent:l}=i,c=o||u;return{id:n,fullExtent:c&&q.fromJSON(c),timeExtent:l&&D.fromJSON({start:l[0],end:l[1]})}})}async queryAttachments(e,t={}){await this.load();const r=this._getLayerRequestOptions(t);return this.queryTask.executeAttachmentQuery(e,r)}async queryFeatures(e,t){await this.load();const r=await this.queryTask.execute(e,{...t,query:this._createRequestQueryOptions(t)});if(e.outStatistics?.length&&r.features.length){const t=new Map;if(r.features.forEach(r=>{const s=r.attributes;e.outStatistics?.forEach(({outStatisticFieldName:e})=>{if(e){const r=e.toLowerCase();r&&r in s&&e!==r&&(s[e]=s[r],delete s[r],t.set(r,e))}})}),null!=r.fields)for(const e of r.fields){const r=t.get(e.name.toLowerCase());null!=r&&(e.name=r)}}return r}async queryFeaturesJSON(e,t){return await this.load(),this.queryTask.executeJSON(e,{...t,query:this._createRequestQueryOptions(t)})}async queryObjectIds(e,t){return await this.load(),this.queryTask.executeForIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryFeatureCount(e,t){return await this.load(),this.queryTask.executeForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryExtent(e,t){return await this.load(),this.queryTask.executeForExtent(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeatures(e,t){return await this.load(),this.queryTask.executeRelationshipQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryRelatedFeaturesCount(e,t){return await this.load(),this.queryTask.executeRelationshipQueryForCount(e,{...t,query:this._createRequestQueryOptions(t)})}async queryPivot(e,t){return await this.load(),this.queryTask.executePivotQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopFeatures(e,t){return await this.load(),this.queryTask.executeTopFeaturesQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryAttributeBins(e,t){return await this.load(),this.queryTask.executeAttributeBinsQuery(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopObjectIds(e,t){return await this.load(),this.queryTask.executeForTopIds(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopExtents(e,t){return await this.load(),this.queryTask.executeForTopExtents(e,{...t,query:this._createRequestQueryOptions(t)})}async queryTopCount(e,t){return await this.load(),this.queryTask.executeForTopCount(e,{...t,query:this._createRequestQueryOptions(t)})}async fetchPublishingStatus(){if(!T(this.layer.url))return"unavailable";const e=h(this.layer.url,"status"),t=await r(e,{query:{f:"json"}});return B.fromJSON(t.data.status)}async uploadAssets(e,t){const{uploadAssets:r}=await(import("./support/uploadAssets.js"));return r(e,{layer:this.layer,ongoingUploads:this._ongoingAssetUploads},t)}_handleLastEditsEventChange(e){const t=this.layer;if(null==e||!("capabilities"in t)||!("effectiveCapabilities"in t))return;if(!(!t.capabilities?.operations?.supportsEditing&&t.effectiveCapabilities?.operations?.supportsEditing))return;let r=t.url;if(null==r)return;"layerId"in t&&(r=h(r,t.layerId.toString()));this._getOrCreateEditInterceptor(r).before=t=>{const r=t.requestOptions.method??"auto";if("auto"===r||"head"===r){const r=t.requestOptions.query??{};r._ts=e.getTime(),t.requestOptions.query=r}}}_getOrCreateEditInterceptor(e){return null==this._editInterceptor&&(this._editInterceptor={urls:e},t.request.internalInterceptors.push(this._editInterceptor)),this._editInterceptor}_removeEditInterceptor(){null!=this._editInterceptor&&(a(t.request.internalInterceptors,this._editInterceptor),this._editInterceptor=null)}async _asyncApplyEdits(e,t){const s=(await r(e,t)).data.statusUrl;for(;;){const e=(await r(s,{query:{f:"json"},responseType:"json"})).data;switch(e.status){case"Completed":return r(e.resultUrl,{query:{f:"json"},responseType:"json"});case"CompletedWithErrors":throw new i("async-applyEdits-failed","asynchronous applyEdits call failed.");case"Failed ImportChanges":case"InProgress":case"Pending":case"ExportAttachments":case"ExportChanges":case"ExportingData":case"ExportingSnapshot":case"ImportAttachments":case"ProvisioningReplica":case"UnRegisteringReplica":break;default:throw new i("async-applyEdits-failed","asynchronous applyEdits call failed (undefined response status)")}await d(G)}}_createRequestQueryOptions(e){const t={...this.layer.customParameters,token:this.layer.apiKey,...e?.query};return this.layer.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t}async _fetchService(e,t){if(!e){const s={};has("featurelayer-advanced-symbols")&&(s.returnAdvancedSymbols=!0),t?.cacheBust&&(s._ts=Date.now());const{data:a}=await r(this.layer.parsedUrl.path,this._getLayerRequestOptions({query:s,signal:t?.signal}));e=a}this.layer.applyPreferredHost(e),this.sourceJSON=await this._patchServiceJSON(e,t?.signal);const s=e.type;if(!this.supportedSourceTypes.has(s))throw new i("feature-layer-source:unsupported-type",`Source type "${s}" is not supported`)}async _patchServiceJSON(e,t){if("Table"!==e.type&&e.geometryType&&!e?.drawingInfo?.renderer&&!e.defaultSymbol){const t=x(e.geometryType).renderer;l("drawingInfo.renderer",t,e)}if("esriGeometryMultiPatch"===e.geometryType&&e.infoFor3D&&(e.geometryType="mesh"),null==e.extent)try{const{data:s}=await r(this.layer.url,this._getLayerRequestOptions({signal:t}));s.spatialReference&&(e.extent={xmin:0,ymin:0,xmax:0,ymax:0,spatialReference:s.spatialReference})}catch(s){p(s)}return e}async _ensureLatestMetadata(e){if(this.layer.userHasUpdateItemPrivileges&&this.sourceJSON.cacheMaxAge>0)return this._fetchService(null,{...e,cacheBust:!0})}async _uploadMeshesAndGetAssetMapEditsJSON(e){const{addAssetFeatures:t}=e;if(!t?.length)return null;if(await this._areAllAssetsAlreadyMapped(t))return null;const r=e.addFeatures.filter(e=>e.geometry);if(t.length!==r.length+e.updateFeatures.length)throw new i("feature-layer-source:unsupported-mesh-edits","Mixing attribute only edits with mesh geometry edits is not currently supported");const s=new Array,a=new Map;for(const i of t){const{geometry:e}=i,{vertexSpace:t}=e;if(E(t))s.push(e);else{const t=e.origin,{convertMeshVertexSpace:r}=await(import("../../../geometry/support/meshUtils/convertMeshVertexSpace.js")),n=await r(e,new S({origin:[t.x,t.y,t.z??0]}));a.set(n,e),i.geometry=n,s.push(n)}}await this.uploadAssets(s);for(const[i,n]of a)n.addExternalSources(i.metadata.externalSources.items);return{adds:this._getAssetMapEditsJSON(t),updates:[],deletes:[]}}_getAssetMapEditsJSON(e){const t=new Array,r=this.layer.globalIdField,s=this.layer.parsedUrl;for(const a of e){const e=a.geometry,{metadata:i}=e,n=i.getExternalSourcesOnService(s),o=a.getAttribute(r);if(0===n.length){u.getLogger(this).error(`Skipping feature ${o}. The mesh it is associated with has not been uploaded to the service and cannot be mapped to it.`);continue}const{source:l}=n.find(O)??n[0];for(const r of l.assets)1===r.parts.length?t.push({globalId:m(),parentGlobalId:o,assetName:r.assetName,assetHash:r.parts[0].partHash,flags:[]}):u.getLogger(this).error(`Skipping asset ${r.assetName}. It does not have exactly one part, so we cannot map it to a feature.`)}return t}_createEditsResult(e){const t=e.data,{layerId:r}=this.layer,s=[];let a=null;if(Array.isArray(t))for(const n of t)s.push({id:n.id,editedFeatures:n.editedFeatures}),n.id===r&&(a={addResults:n.addResults??[],updateResults:n.updateResults??[],deleteResults:n.deleteResults??[],attachments:n.attachments,editMoment:n.editMoment});else a=t;const i=v(a);if(s.length>0){i.editedFeatureResults=[];for(const e of s){const{editedFeatures:t}=e,r=t?.spatialReference?new w(t.spatialReference):null;i.editedFeatureResults.push({layerId:e.id,editedFeatures:I(t,r)})}}return i}_createAttachmentErrorResult(e,t){const r=t.details.messages?.[0]||t.message,s=t.details.httpStatus||t.details.messageCode;return{objectId:e,globalId:null,error:new i("feature-layer-source:attachment-failure",r,{code:s})}}_getFormDataForAttachment(e,t){const r=e instanceof FormData?e:e&&e.elements?new FormData(e):null;if(r)for(const s in t){const e=t[s];null!=e&&(r.set?r.set(s,e):r.append(s,e))}return r}_getLayerRequestOptions(e={}){const{layer:t,layer:{parsedUrl:r,gdbVersion:s}}=this;return{...e,query:{gdbVersion:s,layer:"dynamicDataSource"in t&&t.dynamicDataSource?JSON.stringify({source:t.dynamicDataSource}):void 0,...r.query,f:"json",...this._createRequestQueryOptions(e)},responseType:"json"}}async _areAllAssetsAlreadyMapped(e){const{layer:t}=this,{globalIdField:r,parsedUrl:a}=t,i="infoFor3D"in t?t.infoFor3D:null;if(null==i||null==r)return!1;const n=N(i);if(null==n)return!1;const o=h(a.path,`../${n.id}`),u=new Array;for(const s of e){if(!(s.geometry.metadata.getExternalSourcesOnService(a).length>0))return!1;u.push(s)}const l=u.map(e=>e.getAttribute(r)).filter(s);if(0===l.length)return!1;const{assetMapFieldRoles:{parentGlobalId:c,assetHash:d}}=i,p=new J({where:`${c} IN (${l.map(e=>`'${e}'`)})`,outFields:[d,c],returnGeometry:!1}),y=await U(o,p),{features:m}=y;return 0!==m.length&&!u.some(e=>{const t=e.getAttribute(r);if(!t)return!0;const{metadata:s}=e.geometry,i=m.filter(e=>e.getAttribute(c)===t);if(0===i.length)return!0;const n=i.map(e=>e.getAttribute(d));return s.getExternalSourcesOnService(a).flatMap(({source:e})=>e.assets.flatMap(e=>e.parts.map(e=>e.partHash))).some(e=>n.every(t=>e!==t))})}};e([f()],$.prototype,"type",void 0),e([f({constructOnly:!0})],$.prototype,"layer",void 0),e([f({constructOnly:!0})],$.prototype,"supportedSourceTypes",void 0),e([f({readOnly:!0})],$.prototype,"queryTask",null),$=e([g("esri.layers.graphics.sources.FeatureLayerSource")],$);const G=1e3;export{$ as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import{clone as i}from"../../core/lang.js";import{hasSameOrigin as r,getHost as o,changeHost as s}from"../../core/urlUtils.js";import{property as n,subclass as p}from"../../core/accessorSupport/decorators.js";import{excludeTables as l}from"../../core/accessorSupport/layerContainerType.js";import{idToName as d}from"../../core/accessorSupport/PropertyOrigin.js";import a from"../../geometry/Extent.js";import u from"../../geometry/HeightModelInfo.js";import c from"../../geometry/SpatialReference.js";import{elevationInfo as y,maxScale as f,minScale as m}from"../support/commonProperties.js";import h from"../support/EditFieldsInfo.js";import{FeatureIndex as v}from"../support/FeatureIndex.js";import{geometryTypeKebabDict as g,hasCurrentUser as I,isLayerCacheStale as F,supportsQueryOnly as S,readGlobalIdField as b,readObjectIdField as j,readVersion as E}from"../support/featureLayerUtils.js";import U from"../support/GeometryFieldsInfo.js";import x from"../support/LayerFloorInfo.js";import{isPreferredUrlApplicable as O,getPreferredUrl as M,applyPreferredHostToPortalItem as D,getPreferredHost as T}from"../support/layerUtils.js";import{urlProperty as w,normalizeParsedUrlObject as C}from"../support/multiLayerServiceUtils.js";import H from"../support/Relationship.js";import{getFeatureLayerCapabilities as R}from"../support/serviceCapabilitiesUtils.js";import B from"../support/Subtype.js";import{hasTypeKeyword as A,typeKeyword as q}from"../../portal/support/portalItemUtils.js";import{timeZoneProperty as Q}from"../../time/timeZoneUtils.js";import{reader as P}from"../../core/accessorSupport/decorators/reader.js";const G=G=>{const V=G;let Z=class extends V{constructor(){super(...arguments),this.cacheMaxAge=0,this.capabilities=null,this.copyright=null,this.dateFieldsTimeZone=null,this.datesInUnknownTimezone=!1,this.definitionExpression=null,this.displayField=null,this.editFieldsInfo=null,this.editingInfo=null,this.elevationInfo=null,this.fieldsIndex=null,this.floorInfo=null,this.fullExtent=null,this.gdbVersion=null,this.geometryFieldsInfo=null,this.geometryType=null,this.globalIdField=null,this.hasM=void 0,this.hasZ=void 0,this.heightModelInfo=null,this.historicMoment=null,this.indexes=new(t.ofType(v)),this.isTable=!1,this.layerId=void 0,this.maxScale=0,this.minScale=0,this.objectIdField=null,this.preferredTimeZone=null,this.relationships=null,this.returnM=void 0,this.returnZ=void 0,this.serviceDefinitionExpression=null,this.serviceItemId=null,this.sourceJSON=null,this.spatialReference=c.WGS84,this.subtypeField=null,this.subtypes=null,this.trackIdField=null,this.uniqueIdFields=null,this.url=null,this.version=void 0,this._isUrlHostModified=!1,this._isUrlHostModificationEnabled=!1}getFieldDomain(e,t){throw new Error("Not implemented")}getField(e){return this.fieldsIndex.get(e)}get authenticationTriggerEvent(){if(!this.url)return null;const{capabilities:e}=this;if(e){const{query:t,operations:i,editing:r}=e;if(!t.supportsQueryByOthers||!t.supportsQueryByAnonymous)return"load";if(i.supportsEditing&&!(r.supportsUpdateByOthers&&r.supportsUpdateByAnonymous&&r.supportsDeleteByOthers&&r.supportsDeleteByAnonymous))return"load"}if(I(this.serviceDefinitionExpression)||I(this.definitionExpression))return"load";if(this.userHasUpdateItemPrivileges){if(F(this))return"load";if(this.hasUpdateItemRestrictions)return e.operations.supportsQuery?"editing":"load"}if(this.userHasFullEditingPrivileges&&this.hasFullEditingRestrictions)return"editing";const t=this.editFieldsInfo;return(t?.creatorField||t?.editorField)&&e?.operations.supportsEditing?"editing":null}readCapabilitiesFromService(e,t){return R(t,this.url)}readEditingInfo(e,t){const{editingInfo:i}=t;return i?{lastEditDate:null!=i.lastEditDate?new Date(i.lastEditDate):null}:null}get effectiveCapabilities(){const e=this.capabilities;if(!e)return null;const t=i(e),{operations:r,editing:o}=t;return S(this)?(this.userHasUpdateItemPrivileges&&(r.supportsQuery=!0),t):this.userHasUpdateItemPrivileges?(r.supportsAdd=r.supportsDelete=r.supportsEditing=r.supportsQuery=r.supportsUpdate=o.supportsDeleteByOthers=o.supportsGeometryUpdate=o.supportsUpdateByOthers=!0,t):(this.userHasFullEditingPrivileges&&r.supportsEditing&&(r.supportsAdd=r.supportsDelete=r.supportsUpdate=o.supportsGeometryUpdate=!0),t)}get effectiveEditingEnabled(){return!1}get effectiveUniqueIdFields(){return this.uniqueIdFields?[...this.uniqueIdFields]:[this.objectIdField]}readGlobalIdFieldFromService(e,t){return b(t)}get hasFullEditingRestrictions(){const e=this.capabilities;if(!e||S(this))return!1;const{operations:t,editing:i}=e;return t.supportsEditing&&!(t.supportsAdd&&t.supportsDelete&&t.supportsUpdate&&i.supportsGeometryUpdate)}get hasUpdateItemRestrictions(){const e=this.capabilities;if(!e)return!1;const{operations:t,editing:i}=e;return S(this)?!t.supportsQuery:!(t.supportsAdd&&t.supportsDelete&&t.supportsEditing&&t.supportsQuery&&t.supportsUpdate&&i.supportsDeleteByOthers&&i.supportsGeometryUpdate&&i.supportsUpdateByOthers)}readIsTableFromService(e,t){return"Table"===t.type}readMaxScale(e,t){return t.effectiveMaxScale||e||0}readMinScale(e,t){return t.effectiveMinScale||e||0}readObjectIdFieldFromService(e,t){return j(t)}get parsedUrl(){return C(this)}readServiceDefinitionExpression(e,t){return t.definitionQuery||t.definitionExpression}readUniqueIdFields(e,t){return t.uniqueIdInfo?.OIDFieldContainsHashValue?t.uniqueIdInfo.fields:null}readVersion(e,t){return E(t)}get isUrlHostModified(){const{loaded:e,url:t,_isUrlHostModified:i}=this;if(i)return!0;if(!e||!t)return!1;if(this.originIdOf("url")<7)return!1;const o=this.sourceJSON?.preferredHost;if(!o)return!1;if(!r(t,`https://${o}`,!0))return!1;for(let s=6;s>=3;s--){const e=this.getAtOrigin("url",d(s));if(e)return!r(t,e,!0)}return!1}applyPreferredHost(e){const{url:t,portalItem:i}=this;if(!t||!O(i))return;const r=M();r&&this._isUrlHostModificationEnabled&&(this._set("url",r),this._isUrlHostModified=!0,i&&D(i,T()))}applyHostFromPortalItem(){const{url:e,portalItem:t}=this;if(!e||7===this.originIdOf("url")||!t?.url||!O(t)||!A(t,q.HOSTED_SERVICE)||r(e,t.url,!0)||!this._isUrlHostModificationEnabled)return;const i=o(t.url);this._set("url",s(e,i)),this._isUrlHostModified=!0}};return e([n({readOnly:!0})],Z.prototype,"authenticationTriggerEvent",null),e([n({readOnly:!0,json:{read:e=>e/60}})],Z.prototype,"cacheMaxAge",void 0),e([n({readOnly:!0,json:{read:!1,origins:{service:{read:{source:["advancedQueryCapabilities","allowGeometryUpdates","allowUpdateWithoutMValues","archivingInfo","capabilities","datesInUnknownTimezone","hasAttachments","hasM","hasZ","isDataBranchVersioned","isDataVersioned","maxRecordCount","maxRecordCountFactor","maxUniqueIDCount","ownershipBasedAccessControlForFeatures","standardMaxRecordCount","standardMaxRecordCountNoGeometry","supportedQueryFormats","supportsAdvancedQueries","supportsApplyEditsWithGlobalIds","supportsAttachmentsByUploadId","supportsAttachmentsResizing","supportsCalculate","supportsCoordinatesQuantization","supportsExceedsLimitStatistics","supportsFieldDescriptionProperty","supportsQuantizationEditMode","supportsRollbackOnFailureParameter","supportsStatistics","supportsTruncate","supportsValidateSql","tileMaxRecordCount","useStandardizedQueries"]}}}}})],Z.prototype,"capabilities",void 0),e([P("service","capabilities")],Z.prototype,"readCapabilitiesFromService",null),e([n({type:String,json:{origins:{service:{read:{source:"copyrightText"}}}}})],Z.prototype,"copyright",void 0),e([n(Q("dateFieldsTimeReference"))],Z.prototype,"dateFieldsTimeZone",void 0),e([n({type:Boolean})],Z.prototype,"datesInUnknownTimezone",void 0),e([n({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],Z.prototype,"definitionExpression",void 0),e([n({type:String,json:{origins:{service:{read:{source:"displayField"}}}}})],Z.prototype,"displayField",void 0),e([n({readOnly:!0,type:h})],Z.prototype,"editFieldsInfo",void 0),e([n({readOnly:!0})],Z.prototype,"editingInfo",void 0),e([P("editingInfo")],Z.prototype,"readEditingInfo",null),e([n({readOnly:!0})],Z.prototype,"effectiveCapabilities",null),e([n()],Z.prototype,"effectiveEditingEnabled",null),e([n({readOnly:!0,type:[String]})],Z.prototype,"effectiveUniqueIdFields",null),e([n((()=>{const e=i(y),t=e.json.origins;return t["web-map"]={read:!1,write:!1},t["portal-item"]={read:!1,write:!1},e})())],Z.prototype,"elevationInfo",void 0),e([n()],Z.prototype,"fieldsIndex",void 0),e([n({type:x,json:{name:"layerDefinition.floorInfo",write:{layerContainerTypes:l}}})],Z.prototype,"floorInfo",void 0),e([n({type:a,json:{origins:{service:{read:{source:"extent"}}}}})],Z.prototype,"fullExtent",void 0),e([n()],Z.prototype,"gdbVersion",void 0),e([n({readOnly:!0,type:U,json:{read:{source:"geometryProperties"}}})],Z.prototype,"geometryFieldsInfo",void 0),e([n({type:["point","polygon","polyline","multipoint","multipatch","mesh"],json:{origins:{service:{read:g.read}}}})],Z.prototype,"geometryType",void 0),e([n({type:String})],Z.prototype,"globalIdField",void 0),e([P("service","globalIdField",["globalIdField","fields"])],Z.prototype,"readGlobalIdFieldFromService",null),e([n({readOnly:!0})],Z.prototype,"hasFullEditingRestrictions",null),e([n({type:Boolean,json:{origins:{service:{read:!0}}}})],Z.prototype,"hasM",void 0),e([n({readOnly:!0})],Z.prototype,"hasUpdateItemRestrictions",null),e([n({type:Boolean,json:{origins:{service:{read:!0}}}})],Z.prototype,"hasZ",void 0),e([n({readOnly:!0,type:u})],Z.prototype,"heightModelInfo",void 0),e([n({type:Date})],Z.prototype,"historicMoment",void 0),e([n({type:t.ofType(v),readOnly:!0})],Z.prototype,"indexes",void 0),e([n({readOnly:!0})],Z.prototype,"isTable",void 0),e([P("service","isTable",["type"])],Z.prototype,"readIsTableFromService",null),e([n({type:Number,json:{origins:{service:{read:{source:"id"}},"portal-item":{read:!1,write:{target:"id"}}},read:!1}})],Z.prototype,"layerId",void 0),e([n(f)],Z.prototype,"maxScale",void 0),e([P("service","maxScale",["maxScale","effectiveMaxScale"])],Z.prototype,"readMaxScale",null),e([n(m)],Z.prototype,"minScale",void 0),e([P("service","minScale",["minScale","effectiveMinScale"])],Z.prototype,"readMinScale",null),e([n({type:String})],Z.prototype,"objectIdField",void 0),e([P("service","objectIdField",["objectIdField","fields"])],Z.prototype,"readObjectIdFieldFromService",null),e([n({readOnly:!0})],Z.prototype,"parsedUrl",null),e([n(Q("preferredTimeReference"))],Z.prototype,"preferredTimeZone",void 0),e([n({type:[H],readOnly:!0})],Z.prototype,"relationships",void 0),e([n({type:Boolean})],Z.prototype,"returnM",void 0),e([n({type:Boolean})],Z.prototype,"returnZ",void 0),e([n({readOnly:!0,json:{write:!1}})],Z.prototype,"serverGens",void 0),e([n({readOnly:!0})],Z.prototype,"serviceDefinitionExpression",void 0),e([P("service","serviceDefinitionExpression",["definitionQuery","definitionExpression"])],Z.prototype,"readServiceDefinitionExpression",null),e([n({type:String,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Z.prototype,"serviceItemId",void 0),e([n()],Z.prototype,"sourceJSON",void 0),e([n({type:c,json:{origins:{service:{read:{source:"extent.spatialReference"}}}}})],Z.prototype,"spatialReference",void 0),e([n({type:String,readOnly:!0,json:{origins:{service:{read:!0}}}})],Z.prototype,"subtypeField",void 0),e([n({type:[B],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],Z.prototype,"subtypes",void 0),e([n({type:String,json:{read:{source:"timeInfo.trackIdField"}}})],Z.prototype,"trackIdField",void 0),e([n({type:[String]})],Z.prototype,"uniqueIdFields",void 0),e([P("service","uniqueIdFields",["uniqueIdInfo.OIDFieldContainsHashValue","uniqueIdInfo.fields"])],Z.prototype,"readUniqueIdFields",null),e([n(w({nonStandardUrlAllowed:!0}))],Z.prototype,"url",void 0),e([n({json:{origins:{service:{read:!0}},read:!1}})],Z.prototype,"version",void 0),e([P("service","version",["currentVersion","capabilities","drawingInfo","hasAttachments","htmlPopupType","relationships","timeInfo","typeIdField","types"])],Z.prototype,"readVersion",null),e([n({readOnly:!0})],Z.prototype,"isUrlHostModified",null),Z=e([p("esri.layers.mixins.FeatureLayerBase")],Z),Z};export{G as FeatureLayerBase};
2
+ import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import{clone as i}from"../../core/lang.js";import{setDeepValue as r}from"../../core/object.js";import{hasSameOrigin as o,getHost as s,changeHost as n}from"../../core/urlUtils.js";import{property as p,subclass as l}from"../../core/accessorSupport/decorators.js";import{excludeTables as d}from"../../core/accessorSupport/layerContainerType.js";import{idToName as a}from"../../core/accessorSupport/PropertyOrigin.js";import u from"../../geometry/Extent.js";import c from"../../geometry/HeightModelInfo.js";import y from"../../geometry/SpatialReference.js";import{elevationInfo as f,maxScale as m,minScale as h}from"../support/commonProperties.js";import v from"../support/EditFieldsInfo.js";import{FeatureIndex as g}from"../support/FeatureIndex.js";import{geometryTypeKebabDict as I,hasCurrentUser as F,isLayerCacheStale as b,supportsQueryOnly as S,readGlobalIdField as j,readObjectIdField as E,readVersion as U}from"../support/featureLayerUtils.js";import x from"../support/GeometryFieldsInfo.js";import O from"../support/LayerFloorInfo.js";import{isPreferredUrlApplicable as M,getPreferredUrl as D,applyPreferredHostToPortalItem as T,getPreferredHost as w}from"../support/layerUtils.js";import{urlProperty as C,normalizeParsedUrlObject as H}from"../support/multiLayerServiceUtils.js";import R from"../support/Relationship.js";import{getFeatureLayerCapabilities as B}from"../support/serviceCapabilitiesUtils.js";import A from"../support/Subtype.js";import{hasTypeKeyword as q,typeKeyword as Q}from"../../portal/support/portalItemUtils.js";import{timeZoneProperty as P}from"../../time/timeZoneUtils.js";import{reader as G}from"../../core/accessorSupport/decorators/reader.js";const V={name:"layerDefinition.timeInfo",read:!0,write:{enabled:!0,writer:(e,t,i,o)=>{if(e){const s=e.toJSON({...o,writeExportOptions:!1});r(i,s,t)}}}},Z=r=>{const Z=r;let _=class extends Z{constructor(){super(...arguments),this.cacheMaxAge=0,this.capabilities=null,this.copyright=null,this.dateFieldsTimeZone=null,this.datesInUnknownTimezone=!1,this.definitionExpression=null,this.displayField=null,this.editFieldsInfo=null,this.editingInfo=null,this.elevationInfo=null,this.fieldsIndex=null,this.floorInfo=null,this.fullExtent=null,this.gdbVersion=null,this.geometryFieldsInfo=null,this.geometryType=null,this.globalIdField=null,this.hasM=void 0,this.hasZ=void 0,this.heightModelInfo=null,this.historicMoment=null,this.indexes=new(t.ofType(g)),this.isTable=!1,this.layerId=void 0,this.maxScale=0,this.minScale=0,this.objectIdField=null,this.preferredTimeZone=null,this.relationships=null,this.returnM=void 0,this.returnZ=void 0,this.serviceDefinitionExpression=null,this.serviceItemId=null,this.sourceJSON=null,this.spatialReference=y.WGS84,this.subtypeField=null,this.subtypes=null,this.timeInfo=null,this.trackIdField=null,this.uniqueIdFields=null,this.url=null,this.version=void 0,this._isUrlHostModified=!1,this._isUrlHostModificationEnabled=!1}getFieldDomain(e,t){throw new Error("Not implemented")}getField(e){return this.fieldsIndex.get(e)}get authenticationTriggerEvent(){if(!this.url)return null;const{capabilities:e}=this;if(e){const{query:t,operations:i,editing:r}=e;if(!t.supportsQueryByOthers||!t.supportsQueryByAnonymous)return"load";if(i.supportsEditing&&!(r.supportsUpdateByOthers&&r.supportsUpdateByAnonymous&&r.supportsDeleteByOthers&&r.supportsDeleteByAnonymous))return"load"}if(F(this.serviceDefinitionExpression)||F(this.definitionExpression))return"load";if(this.userHasUpdateItemPrivileges){if(b(this))return"load";if(this.hasUpdateItemRestrictions)return e.operations.supportsQuery?"editing":"load"}if(this.userHasFullEditingPrivileges&&this.hasFullEditingRestrictions)return"editing";const t=this.editFieldsInfo;return(t?.creatorField||t?.editorField)&&e?.operations.supportsEditing?"editing":null}readCapabilitiesFromService(e,t){return B(t,this.url)}readEditingInfo(e,t){const{editingInfo:i}=t;return i?{lastEditDate:null!=i.lastEditDate?new Date(i.lastEditDate):null}:null}get effectiveCapabilities(){const e=this.capabilities;if(!e)return null;const t=i(e),{operations:r,editing:o}=t;return S(this)?(this.userHasUpdateItemPrivileges&&(r.supportsQuery=!0),t):this.userHasUpdateItemPrivileges?(r.supportsAdd=r.supportsDelete=r.supportsEditing=r.supportsQuery=r.supportsUpdate=o.supportsDeleteByOthers=o.supportsGeometryUpdate=o.supportsUpdateByOthers=!0,t):(this.userHasFullEditingPrivileges&&r.supportsEditing&&(r.supportsAdd=r.supportsDelete=r.supportsUpdate=o.supportsGeometryUpdate=!0),t)}get effectiveEditingEnabled(){return!1}get effectiveUniqueIdFields(){return this.uniqueIdFields?[...this.uniqueIdFields]:[this.objectIdField]}readGlobalIdFieldFromService(e,t){return j(t)}get hasFullEditingRestrictions(){const e=this.capabilities;if(!e||S(this))return!1;const{operations:t,editing:i}=e;return t.supportsEditing&&!(t.supportsAdd&&t.supportsDelete&&t.supportsUpdate&&i.supportsGeometryUpdate)}get hasUpdateItemRestrictions(){const e=this.capabilities;if(!e)return!1;const{operations:t,editing:i}=e;return S(this)?!t.supportsQuery:!(t.supportsAdd&&t.supportsDelete&&t.supportsEditing&&t.supportsQuery&&t.supportsUpdate&&i.supportsDeleteByOthers&&i.supportsGeometryUpdate&&i.supportsUpdateByOthers)}readIsTableFromService(e,t){return"Table"===t.type}readMaxScale(e,t){return t.effectiveMaxScale||e||0}readMinScale(e,t){return t.effectiveMinScale||e||0}readObjectIdFieldFromService(e,t){return E(t)}get parsedUrl(){return H(this)}readServiceDefinitionExpression(e,t){return t.definitionQuery||t.definitionExpression}readUniqueIdFields(e,t){return t.uniqueIdInfo?.OIDFieldContainsHashValue?t.uniqueIdInfo.fields:null}readVersion(e,t){return U(t)}get isUrlHostModified(){const{loaded:e,url:t,_isUrlHostModified:i}=this;if(i)return!0;if(!e||!t)return!1;if(this.originIdOf("url")<7)return!1;const r=this.sourceJSON?.preferredHost;if(!r)return!1;if(!o(t,`https://${r}`,!0))return!1;for(let s=6;s>=3;s--){const e=this.getAtOrigin("url",a(s));if(e)return!o(t,e,!0)}return!1}applyPreferredHost(e){const{url:t,portalItem:i}=this;if(!t||!M(i))return;const r=D();r&&this._isUrlHostModificationEnabled&&(this._set("url",r),this._isUrlHostModified=!0,i&&T(i,w()))}applyHostFromPortalItem(){const{url:e,portalItem:t}=this;if(!e||7===this.originIdOf("url")||!t?.url||!M(t)||!q(t,Q.HOSTED_SERVICE)||o(e,t.url,!0)||!this._isUrlHostModificationEnabled)return;const i=s(t.url);this._set("url",n(e,i)),this._isUrlHostModified=!0}};return e([p({readOnly:!0})],_.prototype,"authenticationTriggerEvent",null),e([p({readOnly:!0,json:{read:e=>e/60}})],_.prototype,"cacheMaxAge",void 0),e([p({readOnly:!0,json:{read:!1,origins:{service:{read:{source:["advancedQueryCapabilities","allowGeometryUpdates","allowUpdateWithoutMValues","archivingInfo","capabilities","datesInUnknownTimezone","hasAttachments","hasM","hasZ","isDataBranchVersioned","isDataVersioned","maxRecordCount","maxRecordCountFactor","maxUniqueIDCount","ownershipBasedAccessControlForFeatures","standardMaxRecordCount","standardMaxRecordCountNoGeometry","supportedQueryFormats","supportsAdvancedQueries","supportsApplyEditsWithGlobalIds","supportsAttachmentsByUploadId","supportsAttachmentsResizing","supportsCalculate","supportsCoordinatesQuantization","supportsExceedsLimitStatistics","supportsFieldDescriptionProperty","supportsQuantizationEditMode","supportsRollbackOnFailureParameter","supportsStatistics","supportsTruncate","supportsValidateSql","tileMaxRecordCount","useStandardizedQueries"]}}}}})],_.prototype,"capabilities",void 0),e([G("service","capabilities")],_.prototype,"readCapabilitiesFromService",null),e([p({type:String,json:{origins:{service:{read:{source:"copyrightText"}}}}})],_.prototype,"copyright",void 0),e([p(P("dateFieldsTimeReference"))],_.prototype,"dateFieldsTimeZone",void 0),e([p({type:Boolean})],_.prototype,"datesInUnknownTimezone",void 0),e([p({type:String,json:{origins:{service:{read:!1,write:!1}},name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],_.prototype,"definitionExpression",void 0),e([p({type:String,json:{origins:{service:{read:{source:"displayField"}}}}})],_.prototype,"displayField",void 0),e([p({readOnly:!0,type:v})],_.prototype,"editFieldsInfo",void 0),e([p({readOnly:!0})],_.prototype,"editingInfo",void 0),e([G("editingInfo")],_.prototype,"readEditingInfo",null),e([p({readOnly:!0})],_.prototype,"effectiveCapabilities",null),e([p()],_.prototype,"effectiveEditingEnabled",null),e([p({readOnly:!0,type:[String]})],_.prototype,"effectiveUniqueIdFields",null),e([p((()=>{const e=i(f),t=e.json.origins;return t["web-map"]={read:!1,write:!1},t["portal-item"]={read:!1,write:!1},e})())],_.prototype,"elevationInfo",void 0),e([p()],_.prototype,"fieldsIndex",void 0),e([p({type:O,json:{name:"layerDefinition.floorInfo",write:{layerContainerTypes:d}}})],_.prototype,"floorInfo",void 0),e([p({type:u,json:{origins:{service:{read:{source:"extent"}}}}})],_.prototype,"fullExtent",void 0),e([p()],_.prototype,"gdbVersion",void 0),e([p({readOnly:!0,type:x,json:{read:{source:"geometryProperties"}}})],_.prototype,"geometryFieldsInfo",void 0),e([p({type:["point","polygon","polyline","multipoint","multipatch","mesh"],json:{origins:{service:{read:I.read}}}})],_.prototype,"geometryType",void 0),e([p({type:String})],_.prototype,"globalIdField",void 0),e([G("service","globalIdField",["globalIdField","fields"])],_.prototype,"readGlobalIdFieldFromService",null),e([p({readOnly:!0})],_.prototype,"hasFullEditingRestrictions",null),e([p({type:Boolean,json:{origins:{service:{read:!0}}}})],_.prototype,"hasM",void 0),e([p({readOnly:!0})],_.prototype,"hasUpdateItemRestrictions",null),e([p({type:Boolean,json:{origins:{service:{read:!0}}}})],_.prototype,"hasZ",void 0),e([p({readOnly:!0,type:c})],_.prototype,"heightModelInfo",void 0),e([p({type:Date})],_.prototype,"historicMoment",void 0),e([p({type:t.ofType(g),readOnly:!0})],_.prototype,"indexes",void 0),e([p({readOnly:!0})],_.prototype,"isTable",void 0),e([G("service","isTable",["type"])],_.prototype,"readIsTableFromService",null),e([p({type:Number,json:{origins:{service:{read:{source:"id"}},"portal-item":{read:!1,write:{target:"id"}}},read:!1}})],_.prototype,"layerId",void 0),e([p(m)],_.prototype,"maxScale",void 0),e([G("service","maxScale",["maxScale","effectiveMaxScale"])],_.prototype,"readMaxScale",null),e([p(h)],_.prototype,"minScale",void 0),e([G("service","minScale",["minScale","effectiveMinScale"])],_.prototype,"readMinScale",null),e([p({type:String})],_.prototype,"objectIdField",void 0),e([G("service","objectIdField",["objectIdField","fields"])],_.prototype,"readObjectIdFieldFromService",null),e([p({readOnly:!0})],_.prototype,"parsedUrl",null),e([p(P("preferredTimeReference"))],_.prototype,"preferredTimeZone",void 0),e([p({type:[R],readOnly:!0})],_.prototype,"relationships",void 0),e([p({type:Boolean})],_.prototype,"returnM",void 0),e([p({type:Boolean})],_.prototype,"returnZ",void 0),e([p({readOnly:!0,json:{write:!1}})],_.prototype,"serverGens",void 0),e([p({readOnly:!0})],_.prototype,"serviceDefinitionExpression",void 0),e([G("service","serviceDefinitionExpression",["definitionQuery","definitionExpression"])],_.prototype,"readServiceDefinitionExpression",null),e([p({type:String,readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],_.prototype,"serviceItemId",void 0),e([p()],_.prototype,"sourceJSON",void 0),e([p({type:y,json:{origins:{service:{read:{source:"extent.spatialReference"}}}}})],_.prototype,"spatialReference",void 0),e([p({type:String,readOnly:!0,json:{origins:{service:{read:!0}}}})],_.prototype,"subtypeField",void 0),e([p({type:[A],readOnly:!0,json:{read:!1,origins:{service:{read:!0}}}})],_.prototype,"subtypes",void 0),e([p({json:{origins:{"web-map":V,"portal-item":V}}})],_.prototype,"timeInfo",void 0),e([p({type:String,json:{read:{source:"timeInfo.trackIdField"}}})],_.prototype,"trackIdField",void 0),e([p({type:[String]})],_.prototype,"uniqueIdFields",void 0),e([G("service","uniqueIdFields",["uniqueIdInfo.OIDFieldContainsHashValue","uniqueIdInfo.fields"])],_.prototype,"readUniqueIdFields",null),e([p(C({nonStandardUrlAllowed:!0}))],_.prototype,"url",void 0),e([p({json:{origins:{service:{read:!0}},read:!1}})],_.prototype,"version",void 0),e([G("service","version",["currentVersion","capabilities","drawingInfo","hasAttachments","htmlPopupType","relationships","timeInfo","typeIdField","types"])],_.prototype,"readVersion",null),e([p({readOnly:!0})],_.prototype,"isUrlHostModified",null),_=e([l("esri.layers.mixins.FeatureLayerBase")],_),_};export{Z as FeatureLayerBase};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * FeatureLayerReload is a mixin that adds support for reloading layer's schema and properties.
3
+ *
4
+ * @since 5.2
5
+ */
6
+ export abstract class FeatureLayerReload {
7
+ constructor(...args: any[]);
8
+ /**
9
+ * Indicates if the layer is in the process of reloading its properties and schema after a call to `reload()`.
10
+ *
11
+ * @since 5.2
12
+ */
13
+ get reloading(): boolean;
14
+ /**
15
+ * Reloads the layer's schema and properties.
16
+ *
17
+ * This method is debounced to prevent redundant, concurrent network requests.
18
+ * If called while an update is already in progress, a single subsequent execution is queued,
19
+ * and any other intermediate calls are discarded.
20
+ *
21
+ * @returns `true` when the layer is successfully updated with data from the portal item or service;
22
+ * `false` when the layer is not updated, not loaded, or does not reference a service.
23
+ * @since 5.2
24
+ */
25
+ reload(): Promise<boolean>;
26
+ }
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as t}from"tslib";import{abortHandle as e}from"../../core/handleUtils.js";import{debounce as r,throwIfAbortError as o}from"../../core/promiseUtils.js";import{property as l,subclass as a}from"../../core/accessorSupport/decorators.js";import{getOwningPortalUrl as i}from"../support/layerUtils.js";import s from"../../portal/Portal.js";import d from"../../portal/PortalItem.js";const n="reload",u=u=>{const p=u;let m=class extends p{constructor(){super(...arguments),this._pendingReloadCount=0,this._reloadServiceItemState=null,this._debounceReload=r(async()=>{if(this.destroyed||!this.loaded||!this.canReload())return!1;const t=new AbortController;this.addHandles(e(t),n);try{let e,r=null;if(this.portalItem?.id)e=await this.reloadFromPortal({supportedTypes:this.supportedPortalItemTypes},{signal:t.signal});else{const o=await this._shouldReloadFromServiceItem(t.signal);e=o.updated,r=o.state}return e&&(await this.reloadFromService(t.signal),r&&(this._reloadServiceItemState=r)),t.signal.throwIfAborted(),e}finally{this.removeHandles(n)}})}get reloading(){return this._pendingReloadCount>0}reload(){return!this.destroyed&&this.loaded&&this.canReload()?(this._pendingReloadCount++,this._debounceReload().finally(()=>{this._pendingReloadCount--})):Promise.resolve(!1)}canReload(){return null!=this.url}async _shouldReloadFromServiceItem(t){const{serviceItemId:e,url:r}=this;if(!e||!r)return{state:null,updated:!0};try{const o=await i(r,{signal:t});if(!o)return{state:null,updated:!0};const l=new s({url:o}),a=new d({apiKey:this.apiKey,id:e,portal:l});await a.load({signal:t});const n=a.modified?.getTime();if(null==n)return{state:null,updated:!0};const u={id:e,modified:n,portalUrl:l.url},p=this._reloadServiceItemState;return{state:u,updated:null==p||p.id!==u.id||p.portalUrl!==u.portalUrl||p.modified!==u.modified}}catch(l){return o(l),{state:null,updated:!0}}}};return t([l({clonable:!1})],m.prototype,"_pendingReloadCount",void 0),t([l({readOnly:!0})],m.prototype,"reloading",null),m=t([a("esri.layers.mixins.FeatureLayerReload")],m),m};export{u as FeatureLayerReload};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../config.js";import{id as r}from"../../kernel.js";import s from"../../request.js";import{result as i}from"../../core/asyncUtils.js";import a from"../../core/Error.js";import{abortHandle as o}from"../../core/handleUtils.js";import l from"../../core/Logger.js";import{destroyMaybe as p}from"../../core/maybe.js";import{throwIfAborted as n,isAbortError as u,throwIfAbortError as d}from"../../core/promiseUtils.js";import{hasSameCanonicalPortal as m,hasSamePortal as c,normalize as h}from"../../core/urlUtils.js";import{property as f,subclass as g}from"../../core/accessorSupport/decorators.js";import{getOwningPortalUrl as y}from"../support/layerUtils.js";import I from"../../portal/Portal.js";import v from"../../portal/PortalItem.js";import P from"../../portal/PortalUser.js";import{getUserPrivileges as w}from"../../portal/support/portalItemUtils.js";import{reader as U}from"../../core/accessorSupport/decorators/reader.js";import{writer as j}from"../../core/accessorSupport/decorators/writer.js";const _=_=>{const H=_;let b=class extends H{constructor(){super(...arguments),this.resourceReferences={portalItem:null,paths:[]},this.userHasEditingPrivileges=!0,this.userHasFullEditingPrivileges=!1,this.userHasUpdateItemPrivileges=!1}destroy(){super.destroy(),this.portalItem=p(this.portalItem),this.resourceReferences.portalItem=null,this.resourceReferences.paths.length=0}get portalItem(){return this._get("portalItem")}set portalItem(t){t!==this._get("portalItem")&&(this.removeOrigin("portal-item"),this._set("portalItem",t))}readPortalItem(t,e,r){if(e.itemId)return new v({id:e.itemId,portal:r?.portal})}writePortalItem(t,e){t?.id&&(e.itemId=t.id)}async loadFromPortal(t,e){if(this.portalItem?.id)try{const{load:r}=await(import("../../portal/support/layersLoader.js"));return n(e),await r({instance:this,supportedTypes:t.supportedTypes,validateItem:t.validateItem,supportsData:t.supportsData,layerModuleTypeMap:t.layerModuleTypeMap,populateGroupLayer:t.populateGroupLayer},e)}catch(r){throw u(r)||l.getLogger(this).warn(`Failed to load layer (${this.title}, ${this.id}) portal item (${this.portalItem.id})\n ${r}`),r}}async reloadFromPortal(t){if(!this.loaded||!this.portalItem?.id)return!1;try{const{reload:e}=await(import("../../portal/support/layersLoader.js")),r=new AbortController,s=o(r);return this.addHandles(s,"reloadFromPortal"),await e({instance:this,supportedTypes:t.supportedTypes,validateItem:t.validateItem,supportsData:t.supportsData,layerModuleTypeMap:t.layerModuleTypeMap,populateGroupLayer:t.populateGroupLayer},{signal:r.signal})}catch(e){throw u(e)||l.getLogger(this).warn(`Failed to reload layer (${this.title}, ${this.id}) portal item (${this.portalItem.id})\n ${e}`),e}finally{this.removeHandles("reloadFromPortal")}}async finishLoadEditablePortalLayer(t){this._set("userHasEditingPrivileges",await this._fetchUserHasEditingPrivileges(t).catch(t=>(d(t),!0)))}async setUserPrivileges(t,r){if(!e.userPrivilegesApplied)return this.finishLoadEditablePortalLayer(r);if(this.url)try{const{features:{edit:e,fullEdit:s},content:{updateItem:i}}=await this._fetchUserPrivileges(t,r);this._set("userHasEditingPrivileges",e),this._set("userHasFullEditingPrivileges",s),this._set("userHasUpdateItemPrivileges",i)}catch(s){d(s)}}async _fetchUserPrivileges(t,e){let s=this.portalItem;if(!t||!s||!s.loaded||s.sourceUrl)return this._fetchFallbackUserPrivileges(e);const i=!r?.findCredential(this.url),a=t===s.id;if(a&&s.portal.user)return this._getUserPrivileges(s,i);let o,l;if(a)o=s.portal.url;else try{o=await y(this.url,e)}catch(c){d(c)}if(!o||!m(o,s.portal.url))return this._fetchFallbackUserPrivileges(e);try{const t=null!=e?e.signal:null;l=await(r?.getCredential(`${o}/sharing`,{prompt:!1,signal:t}))}catch(c){d(c)}const p=!0,n=!1,u=!1;if(!l)return{features:{edit:p,fullEdit:n},content:{updateItem:u}};try{if(a?await s.reload():(s=new v({id:t,portal:{url:o}}),await s.load(e)),s.portal.user)return this._getUserPrivileges(s,i)}catch(c){d(c)}return{features:{edit:p,fullEdit:n},content:{updateItem:u}}}_getUserPrivileges(t,e){const r=w(t);return e&&(r.features.edit=!0),r}async _fetchFallbackUserPrivileges(t){let e=!0;try{e=await this._fetchUserHasEditingPrivileges(t)}catch(r){d(r)}return{features:{edit:e,fullEdit:!1},content:{updateItem:!1}}}async _fetchUserHasEditingPrivileges(t){const e=this.url?r?.findCredential(this.url):null;if(!e)return!0;const s=E.credential===e?E.user:await this._fetchEditingUser(t);return E.credential=e,E.user=s,null==s?.privileges||s.privileges.includes("features:user:edit")}async _fetchEditingUser(t){const e=this.portalItem?.portal?.user;if(e)return e;const a=r?.findServerInfo(this.url??"");if(!a?.owningSystemUrl)return null;const o=`${a.owningSystemUrl}/sharing/rest`,l=I.getDefault();if(l&&l.loaded&&h(l.restUrl)===h(o))return l.user;const p=`${o}/community/self`,n=null!=t?t.signal:null,u=await i(s(p,{authMode:"no-prompt",query:{f:"json"},signal:n}));return u.ok?P.fromJSON(u.value.data):null}read(t,e){e&&(e.layer=this),super.read(t,e)}write(t,e){const r=e?.portal,s=this.portalItem?.id&&(this.portalItem.portal||I.getDefault());return r&&s&&!c(s.restUrl,r.restUrl)?(e.messages&&e.messages.push(new a("layer:cross-portal",`The layer '${this.title} (${this.id})' cannot be persisted because it refers to an item on a different portal than the one being saved to. To save, set layer.portalItem to null or save to the same portal as the item associated with the layer`,{layer:this})),null):super.write(t,{...e,layer:this})}};return t([f({type:v})],b.prototype,"portalItem",null),t([U("web-document","portalItem",["itemId"])],b.prototype,"readPortalItem",null),t([j("web-document","portalItem",{itemId:{type:String}})],b.prototype,"writePortalItem",null),t([f({clonable:!1})],b.prototype,"resourceReferences",void 0),t([f({type:Boolean,readOnly:!0})],b.prototype,"userHasEditingPrivileges",void 0),t([f({type:Boolean,readOnly:!0})],b.prototype,"userHasFullEditingPrivileges",void 0),t([f({type:Boolean,readOnly:!0})],b.prototype,"userHasUpdateItemPrivileges",void 0),b=t([g("esri.layers.mixins.PortalLayer")],b),b},E={credential:null,user:null};export{_ as PortalLayer};
2
+ import{__decorate as t}from"tslib";import e from"../../config.js";import{id as r}from"../../kernel.js";import s from"../../request.js";import{result as i}from"../../core/asyncUtils.js";import a from"../../core/Error.js";import{abortHandle as o}from"../../core/handleUtils.js";import l from"../../core/Logger.js";import{destroyMaybe as p}from"../../core/maybe.js";import{throwIfAborted as n,isAbortError as u,throwIfAbortError as d}from"../../core/promiseUtils.js";import{hasSameCanonicalPortal as m,hasSamePortal as c,normalize as h}from"../../core/urlUtils.js";import{property as f,subclass as g}from"../../core/accessorSupport/decorators.js";import{getOwningPortalUrl as y}from"../support/layerUtils.js";import I from"../../portal/Portal.js";import v from"../../portal/PortalItem.js";import P from"../../portal/PortalUser.js";import{getUserPrivileges as w}from"../../portal/support/portalItemUtils.js";import{reader as U}from"../../core/accessorSupport/decorators/reader.js";import{writer as j}from"../../core/accessorSupport/decorators/writer.js";const _=_=>{const H=_;let b=class extends H{constructor(){super(...arguments),this.resourceReferences={portalItem:null,paths:[]},this.userHasEditingPrivileges=!0,this.userHasFullEditingPrivileges=!1,this.userHasUpdateItemPrivileges=!1}destroy(){super.destroy(),this.portalItem=p(this.portalItem),this.resourceReferences.portalItem=null,this.resourceReferences.paths.length=0}get portalItem(){return this._get("portalItem")}set portalItem(t){t!==this._get("portalItem")&&(this.removeOrigin("portal-item"),this._set("portalItem",t))}readPortalItem(t,e,r){if(e.itemId)return new v({id:e.itemId,portal:r?.portal})}writePortalItem(t,e){t?.id&&(e.itemId=t.id)}async loadFromPortal(t,e){if(this.portalItem?.id)try{const{load:r}=await(import("../../portal/support/layersLoader.js"));return n(e),await r({instance:this,supportedTypes:t.supportedTypes,validateItem:t.validateItem,supportsData:t.supportsData,layerModuleTypeMap:t.layerModuleTypeMap,populateGroupLayer:t.populateGroupLayer},e)}catch(r){throw u(r)||l.getLogger(this).warn(`Failed to load layer (${this.title}, ${this.id}) portal item (${this.portalItem.id})\n ${r}`),r}}async reloadFromPortal(t,e){if(!this.loaded||!this.portalItem?.id)return!1;const r=e?.signal?null:new AbortController;try{const{reload:s}=await(import("../../portal/support/layersLoader.js"));return r&&this.addHandles(o(r),"reloadFromPortal"),await s({instance:this,supportedTypes:t.supportedTypes,validateItem:t.validateItem,supportsData:t.supportsData,layerModuleTypeMap:t.layerModuleTypeMap,populateGroupLayer:t.populateGroupLayer},e?.signal?e:{signal:r.signal})}catch(s){throw u(s)||l.getLogger(this).warn(`Failed to reload layer (${this.title}, ${this.id}) portal item (${this.portalItem.id})\n ${s}`),s}finally{r&&this.removeHandles("reloadFromPortal")}}async finishLoadEditablePortalLayer(t){this._set("userHasEditingPrivileges",await this._fetchUserHasEditingPrivileges(t).catch(t=>(d(t),!0)))}async setUserPrivileges(t,r){if(!e.userPrivilegesApplied)return this.finishLoadEditablePortalLayer(r);if(this.url)try{const{features:{edit:e,fullEdit:s},content:{updateItem:i}}=await this._fetchUserPrivileges(t,r);this._set("userHasEditingPrivileges",e),this._set("userHasFullEditingPrivileges",s),this._set("userHasUpdateItemPrivileges",i)}catch(s){d(s)}}async _fetchUserPrivileges(t,e){let s=this.portalItem;if(!t||!s||!s.loaded||s.sourceUrl)return this._fetchFallbackUserPrivileges(e);const i=!r?.findCredential(this.url),a=t===s.id;if(a&&s.portal.user)return this._getUserPrivileges(s,i);let o,l;if(a)o=s.portal.url;else try{o=await y(this.url,e)}catch(c){d(c)}if(!o||!m(o,s.portal.url))return this._fetchFallbackUserPrivileges(e);try{const t=null!=e?e.signal:null;l=await(r?.getCredential(`${o}/sharing`,{prompt:!1,signal:t}))}catch(c){d(c)}const p=!0,n=!1,u=!1;if(!l)return{features:{edit:p,fullEdit:n},content:{updateItem:u}};try{if(a?await s.reload():(s=new v({id:t,portal:{url:o}}),await s.load(e)),s.portal.user)return this._getUserPrivileges(s,i)}catch(c){d(c)}return{features:{edit:p,fullEdit:n},content:{updateItem:u}}}_getUserPrivileges(t,e){const r=w(t);return e&&(r.features.edit=!0),r}async _fetchFallbackUserPrivileges(t){let e=!0;try{e=await this._fetchUserHasEditingPrivileges(t)}catch(r){d(r)}return{features:{edit:e,fullEdit:!1},content:{updateItem:!1}}}async _fetchUserHasEditingPrivileges(t){const e=this.url?r?.findCredential(this.url):null;if(!e)return!0;const s=E.credential===e?E.user:await this._fetchEditingUser(t);return E.credential=e,E.user=s,null==s?.privileges||s.privileges.includes("features:user:edit")}async _fetchEditingUser(t){const e=this.portalItem?.portal?.user;if(e)return e;const a=r?.findServerInfo(this.url??"");if(!a?.owningSystemUrl)return null;const o=`${a.owningSystemUrl}/sharing/rest`,l=I.getDefault();if(l&&l.loaded&&h(l.restUrl)===h(o))return l.user;const p=`${o}/community/self`,n=null!=t?t.signal:null,u=await i(s(p,{authMode:"no-prompt",query:{f:"json"},signal:n}));return u.ok?P.fromJSON(u.value.data):null}read(t,e){e&&(e.layer=this),super.read(t,e)}write(t,e){const r=e?.portal,s=this.portalItem?.id&&(this.portalItem.portal||I.getDefault());return r&&s&&!c(s.restUrl,r.restUrl)?(e.messages&&e.messages.push(new a("layer:cross-portal",`The layer '${this.title} (${this.id})' cannot be persisted because it refers to an item on a different portal than the one being saved to. To save, set layer.portalItem to null or save to the same portal as the item associated with the layer`,{layer:this})),null):super.write(t,{...e,layer:this})}};return t([f({type:v})],b.prototype,"portalItem",null),t([U("web-document","portalItem",["itemId"])],b.prototype,"readPortalItem",null),t([j("web-document","portalItem",{itemId:{type:String}})],b.prototype,"writePortalItem",null),t([f({clonable:!1})],b.prototype,"resourceReferences",void 0),t([f({type:Boolean,readOnly:!0})],b.prototype,"userHasEditingPrivileges",void 0),t([f({type:Boolean,readOnly:!0})],b.prototype,"userHasFullEditingPrivileges",void 0),t([f({type:Boolean,readOnly:!0})],b.prototype,"userHasUpdateItemPrivileges",void 0),b=t([g("esri.layers.mixins.PortalLayer")],b),b},E={credential:null,user:null};export{_ as PortalLayer};
@@ -13,7 +13,7 @@ export interface TimeInfoProperties extends Partial<Pick<TimeInfo, "endField" |
13
13
  * @since 4.12
14
14
  * @example
15
15
  * const { start, end } = featureLayer.timeInfo.fullTimeExtent;
16
- * const range = end - start; // milliseconds
16
+ * const range = end.getTime() - start.getTime(); // milliseconds
17
17
  * const days = range / ( 1000 * 60 * 60 * 24 ); // days
18
18
  * console.log(`The layer's temporal extent is ${days} days.`);
19
19
  */
@@ -63,7 +63,7 @@ export default class TimeInfo extends TimeInfoSuperclass {
63
63
  * @since 4.12
64
64
  * @example
65
65
  * const { start, end } = featureLayer.timeInfo.fullTimeExtent;
66
- * const range = end - start; // milliseconds
66
+ * const range = end.getTime() - start.getTime(); // milliseconds
67
67
  * const days = range / ( 1000 * 60 * 60 * 24 ); // days
68
68
  * console.log(`The layer's temporal extent is ${days} days.`);
69
69
  */
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{ClonableMixin as e}from"../../core/Clonable.js";import{JSONSupport as l}from"../../core/JSONSupport.js";import{property as r,subclass as i}from"../../core/accessorSupport/decorators.js";import o from"../../time/TimeExtent.js";import n from"../../time/TimeInterval.js";import{timeZoneProperty as a}from"../../time/timeZoneUtils.js";import{reader as m}from"../../core/accessorSupport/decorators/reader.js";import{writer as s}from"../../core/accessorSupport/decorators/writer.js";function p(t,e){return n.fromJSON({value:t,unit:e})}let u=class extends(e(l)){constructor(t){super(t),this.cumulative=!1,this.endField=null,this.fullTimeExtent=null,this.hasLiveData=!1,this.interval=null,this.startField=null,this.timeZone=null,this.trackIdField=null,this.useTime=!0,this.stops=null}readFullTimeExtent(t,e){return e.timeExtent&&Array.isArray(e.timeExtent)&&2===e.timeExtent.length?o.fromArray(e.timeExtent):null}writeFullTimeExtent(t,e){null!=t?.start&&null!=t.end?e.timeExtent=t.toArray():e.timeExtent=null}readInterval(t,e){return e.timeInterval&&e.timeIntervalUnits?p(e.timeInterval,e.timeIntervalUnits):e.defaultTimeInterval&&e.defaultTimeIntervalUnits?p(e.defaultTimeInterval,e.defaultTimeIntervalUnits):null}writeInterval(t,e){e.timeInterval=t?.toJSON().value??null,e.timeIntervalUnits=t?.toJSON().unit??null}};t([r({type:Boolean,json:{name:"exportOptions.timeDataCumulative",write:!0}})],u.prototype,"cumulative",void 0),t([r({type:String,json:{name:"endTimeField",write:{enabled:!0,allowNull:!0}}})],u.prototype,"endField",void 0),t([r({type:o,json:{write:{enabled:!0,allowNull:!0}}})],u.prototype,"fullTimeExtent",void 0),t([m("fullTimeExtent",["timeExtent"])],u.prototype,"readFullTimeExtent",null),t([s("fullTimeExtent")],u.prototype,"writeFullTimeExtent",null),t([r({type:Boolean,json:{write:!0}})],u.prototype,"hasLiveData",void 0),t([r({type:n,json:{write:{enabled:!0,allowNull:!0}}})],u.prototype,"interval",void 0),t([m("interval",["timeInterval","timeIntervalUnits","defaultTimeInterval","defaultTimeIntervalUnits"])],u.prototype,"readInterval",null),t([s("interval")],u.prototype,"writeInterval",null),t([r({type:String,json:{name:"startTimeField",write:{enabled:!0,allowNull:!0}}})],u.prototype,"startField",void 0),t([r(a("timeReference",!0))],u.prototype,"timeZone",void 0),t([r({type:String,json:{write:{enabled:!0,allowNull:!0}}})],u.prototype,"trackIdField",void 0),t([r({type:Boolean,json:{name:"exportOptions.useTime",write:!0}})],u.prototype,"useTime",void 0),t([r({type:[Date],json:{read:!1}})],u.prototype,"stops",void 0),u=t([i("esri.layers.support.TimeInfo")],u);export{u as default};
2
+ import{__decorate as t}from"tslib";import{ClonableMixin as e}from"../../core/Clonable.js";import{JSONSupport as r}from"../../core/JSONSupport.js";import{property as i,subclass as o}from"../../core/accessorSupport/decorators.js";import l from"../../time/TimeExtent.js";import n from"../../time/TimeInterval.js";import{timeZoneProperty as a}from"../../time/timeZoneUtils.js";import{reader as m}from"../../core/accessorSupport/decorators/reader.js";import{writer as s}from"../../core/accessorSupport/decorators/writer.js";function p(t,e,r){return{enabled:!1!==r?.writeExportOptions}}function u(t,e){return n.fromJSON({value:t,unit:e})}let d=class extends(e(r)){constructor(t){super(t),this.cumulative=!1,this.endField=null,this.fullTimeExtent=null,this.hasLiveData=!1,this.interval=null,this.startField=null,this.timeZone=null,this.trackIdField=null,this.useTime=!0,this.stops=null}readFullTimeExtent(t,e){return e.timeExtent&&Array.isArray(e.timeExtent)&&2===e.timeExtent.length?l.fromArray(e.timeExtent):null}writeFullTimeExtent(t,e){null!=t?.start&&null!=t.end&&(e.timeExtent=t.toArray())}readInterval(t,e){return e.timeInterval&&e.timeIntervalUnits?u(e.timeInterval,e.timeIntervalUnits):e.defaultTimeInterval&&e.defaultTimeIntervalUnits?u(e.defaultTimeInterval,e.defaultTimeIntervalUnits):null}writeInterval(t,e){e.timeInterval=t?.toJSON().value??null,e.timeIntervalUnits=t?.toJSON().unit??null}};t([i({type:Boolean,json:{name:"exportOptions.timeDataCumulative",write:{overridePolicy:p}}})],d.prototype,"cumulative",void 0),t([i({type:String,json:{name:"endTimeField",write:!0}})],d.prototype,"endField",void 0),t([i({type:l,json:{write:!0}})],d.prototype,"fullTimeExtent",void 0),t([m("fullTimeExtent",["timeExtent"])],d.prototype,"readFullTimeExtent",null),t([s("fullTimeExtent")],d.prototype,"writeFullTimeExtent",null),t([i({type:Boolean,json:{default:!1,write:!0}})],d.prototype,"hasLiveData",void 0),t([i({type:n,json:{write:!0}})],d.prototype,"interval",void 0),t([m("interval",["timeInterval","timeIntervalUnits","defaultTimeInterval","defaultTimeIntervalUnits"])],d.prototype,"readInterval",null),t([s("interval")],d.prototype,"writeInterval",null),t([i({type:String,json:{name:"startTimeField",write:!0}})],d.prototype,"startField",void 0),t([i(a("timeReference",!0,!1))],d.prototype,"timeZone",void 0),t([i({type:String,json:{write:!0}})],d.prototype,"trackIdField",void 0),t([i({type:Boolean,json:{name:"exportOptions.useTime",write:{overridePolicy:p}}})],d.prototype,"useTime",void 0),t([i({type:[Date],json:{read:!1}})],d.prototype,"stops",void 0),d=t([o("esri.layers.support.TimeInfo")],d);export{d as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../core/Error.js";import{getDeepValue as n,setDeepValue as t}from"../../core/object.js";import{union as i}from"../../core/SetUtils.js";import{parseWhereClause as r}from"../../core/sql.js";import{DomainValidationError as l,getDomainRange as o}from"./domainUtils.js";import{getFieldNameFromSimpleExpression as s}from"../../support/arcadeExpressionUtils.js";import{isStringOrNull as a,isString as u}from"../../support/guards.js";import{loadArcade as f}from"../../support/loadArcade.js";const c=/^([0-9_])/,d=/[^a-z0-9_\u0080-\uffff]+/gi;function p(e){if(null==e)return null;return e.trim().replaceAll(d,"_").replace(c,"F$1")||null}const m=["field","field2","field3","normalizationField","rotationInfo.field","proportionalSymbolInfo.field","proportionalSymbolInfo.normalizationField","colorInfo.field","colorInfo.normalizationField"],y=["field","normalizationField"];function g(e,n){if(null!=e&&null!=n)for(const t of Array.isArray(e)?e:[e])if(F(m,t,n),"visualVariables"in t&&t.visualVariables)for(const e of t.visualVariables)F(y,e,n)}function F(e,i,r){if(e)for(const l of e){const e=n(l,i),o=e&&"function"!=typeof e&&r.get(e);o&&t(l,o.name,i)}}function I(e,n){if(null!=e&&n?.fields?.length)if("startField"in e){const t=n.get(e.startField),i=n.get(e.endField);e.startField=t?.name??null,e.endField=i?.name??null}else{const t=n.get(e.startTimeField),i=n.get(e.endTimeField);e.startTimeField=t?.name??null,e.endTimeField=i?.name??null}}const b=new Set;function w(e,n){return e&&n?(b.clear(),x(b,e,n),Array.from(b).sort()):[]}function x(e,n,t){if(t)if(n?.fields?.length)if(t.includes("*"))for(const{name:i}of n.fields)e.add(i);else for(const i of t)T(e,n,i);else{if(t.includes("*"))return e.clear(),void e.add("*");for(const n of t)null!=n&&e.add(n)}}function T(e,n,t){if("string"==typeof t)if(n){const i=n.get(t);i&&e.add(i.name)}else e.add(t)}function h(e,n){return null==n||null==e?[]:n.includes("*")?(e.fields??[]).map(e=>e.name):n}function _(e,n,t=1){if(!n||!e)return[];if(n.includes("*"))return["*"];const i=w(e,n);return i.length/e.fields.length>=t?["*"]:i}async function E(e,n,t,i){if(!i)return;const r=s(i);if(r)T(e,n,r);else{const{arcadeUtils:r}=await f(),l=r.extractFieldNames(i,t?.partitions??n?.fields?.map(e=>e.name));for(const i of l)T(e,t?.index??n,i)}}async function A(n,t,i){if(i&&"1=1"!==i){const l=await r(i,t);if(!l.isStandardized)throw new e("fieldUtils:collectFilterFields","Where clause is not standardized",{where:i});x(n,t,l.fieldNames)}}function v({displayField:e,fields:n}){return e||(n?.length?S(n):null)}function S(e){return L(e,"name-or-title")||L(e,"unique-identifier")||L(e,"type-or-category")||N(e)}function N(e){for(const n of e){if(!n?.name)continue;const e=n.name.toLowerCase();if(e.includes("name")||e.includes("title"))return n.name}return null}function L(e,n){for(const t of e)if(t?.valueType&&t.valueType===n)return t.name;return null}async function $(e){if(!e)return[];const n=new Set;return await O(n,e),Array.from(n).sort()}async function O(e,n){if(!n)return;const t=n.elevationInfo?.featureExpressionInfo;return t?t.collectRequiredFields(e,n.fieldsIndex):void 0}function M(e,n,t){t.onStatisticExpression?E(e,n,null,t.onStatisticExpression.expression):e.add(t.onStatisticField)}async function D(e,n,t){if(!n||!t||!("fields"in t))return;const i=[],r=t.popupTemplate;i.push(R(e,n,r)),t.fields&&i.push(...t.fields.map(async t=>M(e,n.fieldsIndex,t))),await Promise.all(i)}async function V(e,n){const{fieldsIndex:t,trackInfo:i}=n;if(!n||!i||!t)return;const r=[i.latestObservations.renderer?.collectRequiredFields(e,t),i.previousObservations.renderer?.collectRequiredFields(e,t),i.trackLines.renderer?.collectRequiredFields(e,t)];i.popupTemplate&&r.push(R(e,n,i.popupTemplate));for(const l of[i.latestObservations.labelingInfo,i.previousObservations.labelingInfo,i.trackLines.labelingInfo])if(l)for(const n of l)r.push(ne(e,t,n));await Promise.all(r)}async function R(e,n,t){const i=[];t?.expressionInfos&&i.push(...t.expressionInfos.map(t=>E(e,n.fieldsIndex,null,t.expression)));const r=t?.content;if(Array.isArray(r))for(const l of r)"expression"===l.type&&l.expressionInfo&&i.push(E(e,n.fieldsIndex,null,l.expressionInfo.expression));await Promise.all(i)}async function j(e,n,t){n&&(n.timeInfo&&t?.timeExtent&&x(e,n.fieldsIndex,[n.timeInfo.startField,n.timeInfo.endField]),n.floorInfo&&x(e,n.fieldsIndex,[n.floorInfo.floorField]),null!=t?.where&&await A(e,n.fieldsIndex,t.where))}async function U(e,n,t){n&&t&&await Promise.all(t.map(t=>C(e,n,t)))}async function C(e,n,t){n&&t&&(t.valueExpression?await E(e,n.fieldsIndex,null,t.valueExpression):t.field&&T(e,n.fieldsIndex,t.field))}async function k(e){if(!e)return[];const n="timeInfo"in e&&e.timeInfo;return n?w(e.fieldsIndex,[e.trackIdField,n.startField,n.endField]):[]}function G(e){return e?w(e.fieldsIndex,J(e)):[]}function P(e){if(!e)return[];const n=e.geometryFieldsInfo;return n?w(e.fieldsIndex,[n.shapeAreaField,n.shapeLengthField]):[]}async function q(e,n,t){if(!n||!t)return;const i=n.fieldsIndex;await Promise.all(t.filters.map(n=>A(e,i,n.where)))}const z=new Set(["oid","global-id","guid"]),X=new Set(["oid","global-id"]),B=[/^fnode_$/i,/^tnode_$/i,/^lpoly_$/i,/^rpoly_$/i,/^poly_$/i,/^shape$/i,/^shape_$/i,/^subclass$/i,/^subclass_$/i,/^rings_ok$/i,/^rings_nok$/i,/objectid/i,/^perimeter_/i,/_perimeter$/i,/_i$/i];function Y(e){const n=new Set;W(e).forEach(e=>n.add(e)),P(e).forEach(e=>n.add(e.toLowerCase()));const t=e&&"infoFor3D"in e?e.infoFor3D:void 0;return t&&(Object.values(t.assetMapFieldRoles).forEach(e=>n.add(e.toLowerCase())),Object.values(t.transformFieldRoles).forEach(e=>n.add(e.toLowerCase()))),Array.from(n)}function J(e){if(!e)return[];const n="editFieldsInfo"in e&&e.editFieldsInfo;if(!n)return[];const{creationDateField:t,creatorField:i,editDateField:r,editorField:l}=n;return[t,i,r,l].filter(Boolean)}function W(e){return J(e).map(e=>e.toLowerCase())}function H(e){return!!e.type}function K(e,n){return!!e.editable&&H(e)&&!z.has(e.type)&&!W(n).includes(e.name?.toLowerCase()??"")}function Q(e,n){const t=e.name?.toLowerCase()??"";return!(null!=n?.objectIdField&&t===n.objectIdField.toLowerCase()||null!=n?.globalIdField&&t===n.globalIdField.toLowerCase()||Y(n).includes(t)||X.has(e.type)||B.some(e=>e.test(t)))}async function Z(e){if(!e)return[];const n=new Set;return await ee(n,e),Array.from(n).sort()}async function ee(e,n){const{labelingInfo:t,fieldsIndex:i}=n;t?.length&&await Promise.all(t.map(n=>ne(e,i,n)))}async function ne(e,n,t){if(!t)return;const i=t.getLabelExpression(),r=t.where;if("arcade"===i.type)await E(e,n,null,i.expression);else{const t=i.expression.match(/{[^}]*}/g);t&&t.forEach(t=>{T(e,n,t.slice(1,-1))})}await A(e,n,r)}function te(e){const n=e.defaultValue;return void 0!==n&&ae(e,n)?n:e.nullable?null:void 0}function ie(e){const n="string"==typeof e?{type:e}:e;return be(n)?255:"esriFieldTypeDate"===n.type||"date"===n.type?8:void 0}function re(e){return"number"==typeof e&&!isNaN(e)&&isFinite(e)}function le(e){return null===e||re(e)}function oe(e){return null===e||Number.isInteger(e)}function se(){return!0}function ae(e,n){let t;switch(e.type){case"date":case"integer":case"long":case"small-integer":case"big-integer":case"esriFieldTypeDate":case"esriFieldTypeInteger":case"esriFieldTypeLong":case"esriFieldTypeSmallInteger":case"esriFieldTypeBigInteger":t=e.nullable?oe:Number.isInteger;break;case"double":case"single":case"esriFieldTypeSingle":case"esriFieldTypeDouble":t=e.nullable?le:re;break;case"string":case"esriFieldTypeString":t=e.nullable?a:u;break;default:t=se}return 1===arguments.length?t:t(n)}const ue=["integer","small-integer","big-integer","long"],fe=["single","double"],ce=[...ue,...fe],de=["esriFieldTypeInteger","esriFieldTypeSmallInteger","esriFieldTypeLong","esriFieldTypeBigInteger"],pe=["esriFieldTypeSingle","esriFieldTypeDouble"],me=new Set([...ue,...de]),ye=new Set([...fe,...pe]),ge=i(me,ye);function Fe(e){return null!=e&&me.has(e.type)}function Ie(e){return null!=e&&ge.has(e.type)}function be(e){return null!=e&&("string"===e.type||"esriFieldTypeString"===e.type)}function we(e){return null!=e&&("date"===e.type||"esriFieldTypeDate"===e.type)}function xe(e){return null!=e&&("date-only"===e.type||"esriFieldTypeDateOnly"===e.type)}function Te(e){return null!=e&&("timestamp-offset"===e.type||"esriFieldTypeTimestampOffset"===e.type)}function he(e){return null!=e&&("time-only"===e.type||"esriFieldTypeTimeOnly"===e.type)}function _e(e){return null!=e&&("date"===e.type||"date-only"===e.type||"time-only"===e.type||"timestamp-offset"===e.type)}function Ee(e){return null!=e&&("oid"===e.type||"esriFieldTypeOID"===e.type)}function Ae(e){return null!=e&&("global-id"===e.type||"esriFieldTypeGlobalID"===e.type)}function ve(e,n){return null===Oe(e,n)}const Se={OUT_OF_RANGE:"numeric-range-validation-error::out-of-range"},Ne={INVALID_TYPE:"type-validation-error::invalid-type"};function Le(e){return null==e||"number"==typeof e&&isNaN(e)?null:e}function $e(e){return parseFloat(e.replaceAll("_",""))}function Oe(e,n){return null==e||e.nullable&&null===n?null:ae(e,n)?Ie(e)&&!Me(e.type,Number(n))?Se.OUT_OF_RANGE:null:Ne.INVALID_TYPE}function Me(e,n){const t="string"==typeof e?Ve(e):e;if(!t)return!1;const i=t.min,r=t.max;return t.isInteger?Number.isInteger(n)&&n>=i&&n<=r:n>=i&&n<=r}function De(e,n){const t=o(e,n);return t||(Ie(e)?Ve(e.type):void 0)}function Ve(e){switch(e){case"esriFieldTypeSmallInteger":case"small-integer":return je;case"esriFieldTypeInteger":case"esriFieldTypeLong":case"integer":case"long":return ke;case"esriFieldTypeBigInteger":case"big-integer":return Ge;case"esriFieldTypeSingle":case"single":return qe;case"esriFieldTypeDouble":case"double":return ze}}function Re(e){if(!re(e))return null;if(Number.isInteger(e)){if(e>=je.min&&e<=je.max)return"esriFieldTypeSmallInteger";if(e>=ke.min&&e<=ke.max)return"esriFieldTypeInteger";if(e>=Ge.min&&e<=Ge.max)return"esriFieldTypeBigInteger"}return e>=qe.min&&e<=qe.max?"esriFieldTypeSingle":"esriFieldTypeDouble"}const je={min:-32768,max:32767,isInteger:!0,rawMin:-32768,rawMax:32767},Ue=-2147483648,Ce=2**31-1,ke={min:Ue,max:Ce,isInteger:!0,rawMin:Ue,rawMax:Ce},Ge={min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,isInteger:!0,rawMin:-Number.MAX_SAFE_INTEGER,rawMax:Number.MAX_SAFE_INTEGER},Pe=(2-2**-23)*2**127,qe={min:-Pe,max:Pe,isInteger:!1,rawMin:-Pe,rawMax:Pe},ze={min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInteger:!1,rawMin:-Number.MAX_VALUE,rawMax:Number.MAX_VALUE};function Xe(e,n,t){switch(e){case l.INVALID_CODED_VALUE:return`Value ${t} is not in the coded domain - field: ${n.name}, domain: ${JSON.stringify(n.domain)}`;case l.VALUE_OUT_OF_RANGE:return`Value ${t} is out of the range of valid values - field: ${n.name}, domain: ${JSON.stringify(n.domain)}`;case Ne.INVALID_TYPE:return`Value ${t} is not a valid value for the field type - field: ${n.name}, type: ${n.type}, nullable: ${n.nullable}`;case Se.OUT_OF_RANGE:{const{min:e,max:i}=Ve(n.type);return`Value ${t} is out of range for the number type - field: ${n.name}, type: ${n.type}, value range is ${e} to ${i}`}}}function Be(e,n){return!Ye(e,n,null)}function Ye(e,n,t){if(!e?.attributes||!n){if(null!=t)for(const e of n??[])t.add(e);return!0}const i=new Set(Object.keys(e.attributes));let r=!1;for(const l of n)if(!i.has(l)){if(r=!0,null==t)break;t.add(l)}return r}async function Je(e,n){const t=new Set;for(const i of n)await E(t,e.fieldsIndex,null,i);return Array.from(t).sort()}function We(e){return!!e&&["raster.itempixelvalue","raster.servicepixelvalue"].some(n=>e.toLowerCase().startsWith(n))}async function He(e,n){const t=new Set;return e?.collectRequiredFields&&await e.collectRequiredFields(t,n),Array.from(t).sort()}function Ke(e){const n=e?.match(/{[^}]+}/g);return n?n.map(e=>e.slice(1,-1).split(":")[0].trim()):[]}function Qe(e,n){const{statisticType:t,onStatisticField:i,onStatisticExpression:r}=e,l=n.get(i),o=Ie(l),s=r?.returnType;switch(t){case"avg":case"avg_angle":return l?o||we(l)?"double":null:s&&"number"===s?"double":null;case"count":return"integer";case"min":case"max":return l?o||_e(l)?l?.type??null:null:s&&"number"===s?"double":null;case"sum":return l?o?l?.type??null:null:s&&"number"===s?"double":null;case"mode":return l?l?.type??null:s?"number"===s?"double":"string":null;default:return null}}function Ze(e){const{fieldName:n,fieldsMap:t,normalizedFieldsMap:i}=e;if(!n)return;let r=t.get(n);return r||(r=t.get(en(n))??i.get(nn(n)),r&&t.set(n,r),r)}function en(e){return e.trim().toLowerCase()}function nn(e){return p(e)?.toLowerCase()??""}export{Se as NumericRangeValidationError,Ne as TypeValidationError,en as applyLowerCaseFieldName,Ge as bigIntegerRange,E as collectArcadeFieldNames,q as collectDisplayFilterFields,O as collectElevationFields,D as collectFeatureReductionFields,T as collectField,x as collectFields,j as collectFilterFields,ee as collectLabelingFields,U as collectOrderByInfos,R as collectPopupTemplateFields,A as collectSQLFieldNames,V as collectTrackInfoFields,ze as doubleRange,Ke as extractSubstitutionTemplatesFromString,Be as featureHasFields,w as fixFields,g as fixRendererFields,I as fixTimeInfoFields,pe as floatJSONTypes,fe as floatTypes,Qe as getAggregateFieldType,v as getDisplayFieldName,S as getDisplayFieldNameFromFields,J as getEditTrackingFields,$ as getElevationFields,Je as getExpressionFields,G as getFeatureEditFields,P as getFeatureGeometryFields,ie as getFieldDefaultLength,te as getFieldDefaultValue,Ze as getFieldFromIndex,De as getFieldRange,Z as getLabelingFields,Y as getLowerCaseDefaultHiddenFields,W as getLowerCaseEditTrackingFields,Re as getNumericTypeForValue,He as getRendererFields,k as getTimeFields,de as integerJSONTypes,ke as integerRange,ue as integerTypes,we as isDateField,xe as isDateOnlyField,K as isFieldEditable,Q as isFieldVisibleByDefault,H as isFieldWithType,Ae as isGlobalIDField,Fe as isIntegerField,Me as isNumberInRange,Ie as isNumericField,Ee as isObjectIDField,We as isRasterPixelValueField,be as isStringField,he as isTimeOnlyField,Te as isTimestampOffsetField,ve as isValidFieldValue,ae as isValueMatchingFieldType,nn as lowerCaseNormalizedFieldName,p as normalizeFieldName,ce as numericTypes,_ as packFields,Ye as populateMissingFields,m as rendererFields,Le as sanitizeNullFieldValue,$e as sanitizedParseFloat,qe as singleRange,je as smallIntegerRange,h as unpackFieldNames,Oe as validateFieldValue,Xe as validationErrorToString,y as visualVariableFields};
2
+ import e from"../../core/Error.js";import{getDeepValue as n,setDeepValue as t}from"../../core/object.js";import{union as i}from"../../core/SetUtils.js";import{parseWhereClause as r}from"../../core/sql.js";import{DomainValidationError as l,getDomainRange as o}from"./domainUtils.js";import{getFieldNameFromSimpleExpression as s}from"../../support/arcadeExpressionUtils.js";import{isStringOrNull as a,isString as u}from"../../support/guards.js";import{loadArcade as f}from"../../support/loadArcade.js";const c=/^([0-9_])/,d=/[^a-z0-9_\u0080-\uffff]+/gi;function p(e){if(null==e)return null;return e.trim().replaceAll(d,"_").replace(c,"F$1")||null}const m=["field","field2","field3","normalizationField","rotationInfo.field","proportionalSymbolInfo.field","proportionalSymbolInfo.normalizationField","colorInfo.field","colorInfo.normalizationField"],y=["field","normalizationField"];function g(e,n){if(null!=e&&null!=n)for(const t of Array.isArray(e)?e:[e])if(F(m,t,n),"visualVariables"in t&&t.visualVariables)for(const e of t.visualVariables)F(y,e,n)}function F(e,i,r){if(e)for(const l of e){const e=n(l,i),o=e&&"function"!=typeof e&&r.get(e);o&&t(l,o.name,i)}}function I(e,n){if(null==e||!n?.fields?.length)return;if("startField"in e){const t=n.get(e.startField),i=n.get(e.endField);e.startField=t?.name??null,e.endField=i?.name??null}else{const t=n.get(e.startTimeField),i=n.get(e.endTimeField);e.startTimeField=t?.name??null,e.endTimeField=i?.name??null}const t=n.get(e.trackIdField);e.trackIdField=t?.name??null}const b=new Set;function w(e,n){return e&&n?(b.clear(),x(b,e,n),Array.from(b).sort()):[]}function x(e,n,t){if(t)if(n?.fields?.length)if(t.includes("*"))for(const{name:i}of n.fields)e.add(i);else for(const i of t)T(e,n,i);else{if(t.includes("*"))return e.clear(),void e.add("*");for(const n of t)null!=n&&e.add(n)}}function T(e,n,t){if("string"==typeof t)if(n){const i=n.get(t);i&&e.add(i.name)}else e.add(t)}function h(e,n){return null==n||null==e?[]:n.includes("*")?(e.fields??[]).map(e=>e.name):n}function _(e,n,t=1){if(!n||!e)return[];if(n.includes("*"))return["*"];const i=w(e,n);return i.length/e.fields.length>=t?["*"]:i}async function E(e,n,t,i){if(!i)return;const r=s(i);if(r)T(e,n,r);else{const{arcadeUtils:r}=await f(),l=r.extractFieldNames(i,t?.partitions??n?.fields?.map(e=>e.name));for(const i of l)T(e,t?.index??n,i)}}async function A(n,t,i){if(i&&"1=1"!==i){const l=await r(i,t);if(!l.isStandardized)throw new e("fieldUtils:collectFilterFields","Where clause is not standardized",{where:i});x(n,t,l.fieldNames)}}function v({displayField:e,fields:n}){return e||(n?.length?S(n):null)}function S(e){return L(e,"name-or-title")||L(e,"unique-identifier")||L(e,"type-or-category")||N(e)}function N(e){for(const n of e){if(!n?.name)continue;const e=n.name.toLowerCase();if(e.includes("name")||e.includes("title"))return n.name}return null}function L(e,n){for(const t of e)if(t?.valueType&&t.valueType===n)return t.name;return null}async function $(e){if(!e)return[];const n=new Set;return await O(n,e),Array.from(n).sort()}async function O(e,n){if(!n)return;const t=n.elevationInfo?.featureExpressionInfo;return t?t.collectRequiredFields(e,n.fieldsIndex):void 0}function M(e,n,t){t.onStatisticExpression?E(e,n,null,t.onStatisticExpression.expression):e.add(t.onStatisticField)}async function D(e,n,t){if(!n||!t||!("fields"in t))return;const i=[],r=t.popupTemplate;i.push(R(e,n,r)),t.fields&&i.push(...t.fields.map(async t=>M(e,n.fieldsIndex,t))),await Promise.all(i)}async function V(e,n){const{fieldsIndex:t,trackInfo:i}=n;if(!n||!i||!t)return;const r=[i.latestObservations.renderer?.collectRequiredFields(e,t),i.previousObservations.renderer?.collectRequiredFields(e,t),i.trackLines.renderer?.collectRequiredFields(e,t)];i.popupTemplate&&r.push(R(e,n,i.popupTemplate));for(const l of[i.latestObservations.labelingInfo,i.previousObservations.labelingInfo,i.trackLines.labelingInfo])if(l)for(const n of l)r.push(ne(e,t,n));await Promise.all(r)}async function R(e,n,t){const i=[];t?.expressionInfos&&i.push(...t.expressionInfos.map(t=>E(e,n.fieldsIndex,null,t.expression)));const r=t?.content;if(Array.isArray(r))for(const l of r)"expression"===l.type&&l.expressionInfo&&i.push(E(e,n.fieldsIndex,null,l.expressionInfo.expression));await Promise.all(i)}async function j(e,n,t){n&&(n.timeInfo&&t?.timeExtent&&x(e,n.fieldsIndex,[n.timeInfo.startField,n.timeInfo.endField]),n.floorInfo&&x(e,n.fieldsIndex,[n.floorInfo.floorField]),null!=t?.where&&await A(e,n.fieldsIndex,t.where))}async function U(e,n,t){n&&t&&await Promise.all(t.map(t=>k(e,n,t)))}async function k(e,n,t){n&&t&&(t.valueExpression?await E(e,n.fieldsIndex,null,t.valueExpression):t.field&&T(e,n.fieldsIndex,t.field))}async function C(e){if(!e)return[];const n="timeInfo"in e&&e.timeInfo;return n?w(e.fieldsIndex,[e.trackIdField,n.startField,n.endField]):[]}function G(e){return e?w(e.fieldsIndex,J(e)):[]}function P(e){if(!e)return[];const n=e.geometryFieldsInfo;return n?w(e.fieldsIndex,[n.shapeAreaField,n.shapeLengthField]):[]}async function q(e,n,t){if(!n||!t)return;const i=n.fieldsIndex;await Promise.all(t.filters.map(n=>A(e,i,n.where)))}const z=new Set(["oid","global-id","guid"]),X=new Set(["oid","global-id"]),B=[/^fnode_$/i,/^tnode_$/i,/^lpoly_$/i,/^rpoly_$/i,/^poly_$/i,/^shape$/i,/^shape_$/i,/^subclass$/i,/^subclass_$/i,/^rings_ok$/i,/^rings_nok$/i,/objectid/i,/^perimeter_/i,/_perimeter$/i,/_i$/i];function Y(e){const n=new Set;W(e).forEach(e=>n.add(e)),P(e).forEach(e=>n.add(e.toLowerCase()));const t=e&&"infoFor3D"in e?e.infoFor3D:void 0;return t&&(Object.values(t.assetMapFieldRoles).forEach(e=>n.add(e.toLowerCase())),Object.values(t.transformFieldRoles).forEach(e=>n.add(e.toLowerCase()))),Array.from(n)}function J(e){if(!e)return[];const n="editFieldsInfo"in e&&e.editFieldsInfo;if(!n)return[];const{creationDateField:t,creatorField:i,editDateField:r,editorField:l}=n;return[t,i,r,l].filter(Boolean)}function W(e){return J(e).map(e=>e.toLowerCase())}function H(e){return!!e.type}function K(e,n){return!!e.editable&&H(e)&&!z.has(e.type)&&!W(n).includes(e.name?.toLowerCase()??"")}function Q(e,n){const t=e.name?.toLowerCase()??"";return!(null!=n?.objectIdField&&t===n.objectIdField.toLowerCase()||null!=n?.globalIdField&&t===n.globalIdField.toLowerCase()||Y(n).includes(t)||X.has(e.type)||B.some(e=>e.test(t)))}async function Z(e){if(!e)return[];const n=new Set;return await ee(n,e),Array.from(n).sort()}async function ee(e,n){const{labelingInfo:t,fieldsIndex:i}=n;t?.length&&await Promise.all(t.map(n=>ne(e,i,n)))}async function ne(e,n,t){if(!t)return;const i=t.getLabelExpression(),r=t.where;if("arcade"===i.type)await E(e,n,null,i.expression);else{const t=i.expression.match(/{[^}]*}/g);t&&t.forEach(t=>{T(e,n,t.slice(1,-1))})}await A(e,n,r)}function te(e){const n=e.defaultValue;return void 0!==n&&ae(e,n)?n:e.nullable?null:void 0}function ie(e){const n="string"==typeof e?{type:e}:e;return be(n)?255:"esriFieldTypeDate"===n.type||"date"===n.type?8:void 0}function re(e){return"number"==typeof e&&!isNaN(e)&&isFinite(e)}function le(e){return null===e||re(e)}function oe(e){return null===e||Number.isInteger(e)}function se(){return!0}function ae(e,n){let t;switch(e.type){case"date":case"integer":case"long":case"small-integer":case"big-integer":case"esriFieldTypeDate":case"esriFieldTypeInteger":case"esriFieldTypeLong":case"esriFieldTypeSmallInteger":case"esriFieldTypeBigInteger":t=e.nullable?oe:Number.isInteger;break;case"double":case"single":case"esriFieldTypeSingle":case"esriFieldTypeDouble":t=e.nullable?le:re;break;case"string":case"esriFieldTypeString":t=e.nullable?a:u;break;default:t=se}return 1===arguments.length?t:t(n)}const ue=["integer","small-integer","big-integer","long"],fe=["single","double"],ce=[...ue,...fe],de=["esriFieldTypeInteger","esriFieldTypeSmallInteger","esriFieldTypeLong","esriFieldTypeBigInteger"],pe=["esriFieldTypeSingle","esriFieldTypeDouble"],me=new Set([...ue,...de]),ye=new Set([...fe,...pe]),ge=i(me,ye);function Fe(e){return null!=e&&me.has(e.type)}function Ie(e){return null!=e&&ge.has(e.type)}function be(e){return null!=e&&("string"===e.type||"esriFieldTypeString"===e.type)}function we(e){return null!=e&&("date"===e.type||"esriFieldTypeDate"===e.type)}function xe(e){return null!=e&&("date-only"===e.type||"esriFieldTypeDateOnly"===e.type)}function Te(e){return null!=e&&("timestamp-offset"===e.type||"esriFieldTypeTimestampOffset"===e.type)}function he(e){return null!=e&&("time-only"===e.type||"esriFieldTypeTimeOnly"===e.type)}function _e(e){return null!=e&&("date"===e.type||"date-only"===e.type||"time-only"===e.type||"timestamp-offset"===e.type)}function Ee(e){return null!=e&&("oid"===e.type||"esriFieldTypeOID"===e.type)}function Ae(e){return null!=e&&("global-id"===e.type||"esriFieldTypeGlobalID"===e.type)}function ve(e,n){return null===Oe(e,n)}const Se={OUT_OF_RANGE:"numeric-range-validation-error::out-of-range"},Ne={INVALID_TYPE:"type-validation-error::invalid-type"};function Le(e){return null==e||"number"==typeof e&&isNaN(e)?null:e}function $e(e){return parseFloat(e.replaceAll("_",""))}function Oe(e,n){return null==e||e.nullable&&null===n?null:ae(e,n)?Ie(e)&&!Me(e.type,Number(n))?Se.OUT_OF_RANGE:null:Ne.INVALID_TYPE}function Me(e,n){const t="string"==typeof e?Ve(e):e;if(!t)return!1;const i=t.min,r=t.max;return t.isInteger?Number.isInteger(n)&&n>=i&&n<=r:n>=i&&n<=r}function De(e,n){const t=o(e,n);return t||(Ie(e)?Ve(e.type):void 0)}function Ve(e){switch(e){case"esriFieldTypeSmallInteger":case"small-integer":return je;case"esriFieldTypeInteger":case"esriFieldTypeLong":case"integer":case"long":return Ce;case"esriFieldTypeBigInteger":case"big-integer":return Ge;case"esriFieldTypeSingle":case"single":return qe;case"esriFieldTypeDouble":case"double":return ze}}function Re(e){if(!re(e))return null;if(Number.isInteger(e)){if(e>=je.min&&e<=je.max)return"esriFieldTypeSmallInteger";if(e>=Ce.min&&e<=Ce.max)return"esriFieldTypeInteger";if(e>=Ge.min&&e<=Ge.max)return"esriFieldTypeBigInteger"}return e>=qe.min&&e<=qe.max?"esriFieldTypeSingle":"esriFieldTypeDouble"}const je={min:-32768,max:32767,isInteger:!0,rawMin:-32768,rawMax:32767},Ue=-2147483648,ke=2**31-1,Ce={min:Ue,max:ke,isInteger:!0,rawMin:Ue,rawMax:ke},Ge={min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,isInteger:!0,rawMin:-Number.MAX_SAFE_INTEGER,rawMax:Number.MAX_SAFE_INTEGER},Pe=(2-2**-23)*2**127,qe={min:-Pe,max:Pe,isInteger:!1,rawMin:-Pe,rawMax:Pe},ze={min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInteger:!1,rawMin:-Number.MAX_VALUE,rawMax:Number.MAX_VALUE};function Xe(e,n,t){switch(e){case l.INVALID_CODED_VALUE:return`Value ${t} is not in the coded domain - field: ${n.name}, domain: ${JSON.stringify(n.domain)}`;case l.VALUE_OUT_OF_RANGE:return`Value ${t} is out of the range of valid values - field: ${n.name}, domain: ${JSON.stringify(n.domain)}`;case Ne.INVALID_TYPE:return`Value ${t} is not a valid value for the field type - field: ${n.name}, type: ${n.type}, nullable: ${n.nullable}`;case Se.OUT_OF_RANGE:{const{min:e,max:i}=Ve(n.type);return`Value ${t} is out of range for the number type - field: ${n.name}, type: ${n.type}, value range is ${e} to ${i}`}}}function Be(e,n){return!Ye(e,n,null)}function Ye(e,n,t){if(!e?.attributes||!n){if(null!=t)for(const e of n??[])t.add(e);return!0}const i=new Set(Object.keys(e.attributes));let r=!1;for(const l of n)if(!i.has(l)){if(r=!0,null==t)break;t.add(l)}return r}async function Je(e,n){const t=new Set;for(const i of n)await E(t,e.fieldsIndex,null,i);return Array.from(t).sort()}function We(e){return!!e&&["raster.itempixelvalue","raster.servicepixelvalue"].some(n=>e.toLowerCase().startsWith(n))}async function He(e,n){const t=new Set;return e?.collectRequiredFields&&await e.collectRequiredFields(t,n),Array.from(t).sort()}function Ke(e){const n=e?.match(/{[^}]+}/g);return n?n.map(e=>e.slice(1,-1).split(":")[0].trim()):[]}function Qe(e,n){const{statisticType:t,onStatisticField:i,onStatisticExpression:r}=e,l=n.get(i),o=Ie(l),s=r?.returnType;switch(t){case"avg":case"avg_angle":return l?o||we(l)?"double":null:s&&"number"===s?"double":null;case"count":return"integer";case"min":case"max":return l?o||_e(l)?l?.type??null:null:s&&"number"===s?"double":null;case"sum":return l?o?l?.type??null:null:s&&"number"===s?"double":null;case"mode":return l?l?.type??null:s?"number"===s?"double":"string":null;default:return null}}function Ze(e){const{fieldName:n,fieldsMap:t,normalizedFieldsMap:i}=e;if(!n)return;let r=t.get(n);return r||(r=t.get(en(n))??i.get(nn(n)),r&&t.set(n,r),r)}function en(e){return e.trim().toLowerCase()}function nn(e){return p(e)?.toLowerCase()??""}export{Se as NumericRangeValidationError,Ne as TypeValidationError,en as applyLowerCaseFieldName,Ge as bigIntegerRange,E as collectArcadeFieldNames,q as collectDisplayFilterFields,O as collectElevationFields,D as collectFeatureReductionFields,T as collectField,x as collectFields,j as collectFilterFields,ee as collectLabelingFields,U as collectOrderByInfos,R as collectPopupTemplateFields,A as collectSQLFieldNames,V as collectTrackInfoFields,ze as doubleRange,Ke as extractSubstitutionTemplatesFromString,Be as featureHasFields,w as fixFields,g as fixRendererFields,I as fixTimeInfoFields,pe as floatJSONTypes,fe as floatTypes,Qe as getAggregateFieldType,v as getDisplayFieldName,S as getDisplayFieldNameFromFields,J as getEditTrackingFields,$ as getElevationFields,Je as getExpressionFields,G as getFeatureEditFields,P as getFeatureGeometryFields,ie as getFieldDefaultLength,te as getFieldDefaultValue,Ze as getFieldFromIndex,De as getFieldRange,Z as getLabelingFields,Y as getLowerCaseDefaultHiddenFields,W as getLowerCaseEditTrackingFields,Re as getNumericTypeForValue,He as getRendererFields,C as getTimeFields,de as integerJSONTypes,Ce as integerRange,ue as integerTypes,we as isDateField,xe as isDateOnlyField,K as isFieldEditable,Q as isFieldVisibleByDefault,H as isFieldWithType,Ae as isGlobalIDField,Fe as isIntegerField,Me as isNumberInRange,Ie as isNumericField,Ee as isObjectIDField,We as isRasterPixelValueField,be as isStringField,he as isTimeOnlyField,Te as isTimestampOffsetField,ve as isValidFieldValue,ae as isValueMatchingFieldType,nn as lowerCaseNormalizedFieldName,p as normalizeFieldName,ce as numericTypes,_ as packFields,Ye as populateMissingFields,m as rendererFields,Le as sanitizeNullFieldValue,$e as sanitizedParseFloat,qe as singleRange,je as smallIntegerRange,h as unpackFieldNames,Oe as validateFieldValue,Xe as validationErrorToString,y as visualVariableFields};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "5.2.0-next.117",
3
+ "version": "5.2.0-next.118",
4
4
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
5
5
  "keywords": [
6
6
  "ArcGIS",
@@ -20,7 +20,7 @@
20
20
  "license": "SEE LICENSE IN LICENSE.md",
21
21
  "dependencies": {
22
22
  "@amcharts/amcharts5": "~5.20.6",
23
- "@arcgis/toolkit": "5.2.0-next.117",
23
+ "@arcgis/toolkit": "5.2.0-next.118",
24
24
  "@esri/arcgis-html-sanitizer": "~4.1.0",
25
25
  "@esri/calcite-components": "^5.2.0-next.73",
26
26
  "@vaadin/grid": "~25.2.11",
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- const a="20260920",c="e24c3d27d1f54209f4a92566c14af7742b9e7a5a";export{a as buildDate,c as revision};
2
+ const e="20260921",a="00a434e749187fa2ce04fd4431be5902dc3d7a19";export{e as buildDate,a as revision};