@arcgis/core 5.2.0-next.62 → 5.2.0-next.63

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 (202) hide show
  1. package/WebDocument2D.d.ts +17 -1
  2. package/WebDocument2D.js +1 -1
  3. package/WebLinkChart.js +1 -1
  4. package/WebMap.js +1 -1
  5. package/WebScene.js +1 -1
  6. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  7. package/arcgisGlobal.d.ts +5 -0
  8. package/assets/esri/core/workers/RemoteClient.js +1 -1
  9. package/assets/esri/core/workers/chunks/02dd79beb13eff6be85e.js +1 -0
  10. package/assets/esri/core/workers/chunks/04ffe788d2efc0a076dd.js +1 -0
  11. package/assets/esri/core/workers/chunks/0623acb2bd14a61b65c9.js +29 -0
  12. package/assets/esri/core/workers/chunks/08c2bf9defcece9e049a.js +1 -0
  13. package/assets/esri/core/workers/chunks/0d61c8d348b09179777a.js +1 -0
  14. package/assets/esri/core/workers/chunks/14cd8bb1ad4da8d1d2ca.js +1 -0
  15. package/assets/esri/core/workers/chunks/23a3d8f91caf3136b2aa.js +1 -0
  16. package/assets/esri/core/workers/chunks/{1b68b1b724ad30396723.js → 2426601b8cae7f06af4d.js} +1 -1
  17. package/assets/esri/core/workers/chunks/2a1c6df073e6ca6a6365.js +1 -0
  18. package/assets/esri/core/workers/chunks/{f4891345507df63cff3c.js → 3f775deea48e268411f1.js} +3 -3
  19. package/assets/esri/core/workers/chunks/{e3623e557ab463580fd2.js → 41e821ce229bc56dc1a1.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{17acbf40e7c1cb42d9bd.js → 44b1cdf28269b4fa8a39.js} +1 -1
  21. package/assets/esri/core/workers/chunks/44e8cd4b3dad777ab0c9.js +1 -0
  22. package/assets/esri/core/workers/chunks/456e616f32e7de696d38.js +1 -0
  23. package/assets/esri/core/workers/chunks/54b9667450d066c6f6ce.js +1 -0
  24. package/assets/esri/core/workers/chunks/5dbd8ca7e7b8eb9a0bf7.js +1 -0
  25. package/assets/esri/core/workers/chunks/5e3d5347223f0111f40f.js +1 -0
  26. package/assets/esri/core/workers/chunks/62f3ca0719ac6bc76512.js +1 -0
  27. package/assets/esri/core/workers/chunks/63ede7295938f7010808.js +1 -0
  28. package/assets/esri/core/workers/chunks/687cf21e027f49b44d22.js +1 -0
  29. package/assets/esri/core/workers/chunks/6c98a64d92c9bca78203.js +1 -0
  30. package/assets/esri/core/workers/chunks/{e7402dfd683f82878360.js → 752343d92ed48e674351.js} +1 -1
  31. package/assets/esri/core/workers/chunks/7538a0fe0cec3156769e.js +1 -0
  32. package/assets/esri/core/workers/chunks/{64247e439ef3e1f712e9.js → 7fdd6a5fa062778be55d.js} +1 -1
  33. package/assets/esri/core/workers/chunks/8369edafab7bdc59b95a.js +1 -0
  34. package/assets/esri/core/workers/chunks/{94e9cf8e729ec36de5be.js → 8c535c6a39d2be2ed655.js} +1 -1
  35. package/assets/esri/core/workers/chunks/8e1d4867406753c5483c.js +1 -0
  36. package/assets/esri/core/workers/chunks/92696cce2b980373f9ad.js +1 -0
  37. package/assets/esri/core/workers/chunks/{580451761cadfe308919.js → 9954149def644c371894.js} +1 -1
  38. package/assets/esri/core/workers/chunks/9f65cc6d9f7390bb1d5b.js +1 -0
  39. package/assets/esri/core/workers/chunks/a09ce34fc7c8abe64ed5.js +1 -0
  40. package/assets/esri/core/workers/chunks/{83991475aa54fd5aa008.js → a965d151515b76dd7566.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{128799741dd3c6fc69b9.js → ac4131121230cfc14f21.js} +1 -1
  42. package/assets/esri/core/workers/chunks/afeeb11b39e140303b5a.js +1 -0
  43. package/assets/esri/core/workers/chunks/b13d2da33ec07e9d41ff.js +1 -0
  44. package/assets/esri/core/workers/chunks/{33bd9785bd0b6ccef21b.js → b2cf1d3f0d48eac23a84.js} +1 -1
  45. package/assets/esri/core/workers/chunks/c53b2be005721591e29b.js +1 -0
  46. package/assets/esri/core/workers/chunks/{e287113777a94ded8de6.js → c82ab4f0908290e70ee9.js} +1 -1
  47. package/assets/esri/core/workers/chunks/d456520e4b119a2816b6.js +1 -0
  48. package/assets/esri/core/workers/chunks/d83ea3e4e9ab45334068.js +1 -0
  49. package/assets/esri/core/workers/chunks/{4f59357f535f30a6b5cc.js → d9b83d7dd7d1f7729a91.js} +1 -1
  50. package/assets/esri/core/workers/chunks/dbcec48c4ba104a6d0b5.js +1 -0
  51. package/assets/esri/core/workers/chunks/e02f02040b63d9c2e654.js +1 -0
  52. package/assets/esri/core/workers/chunks/e08c64e4ae5a68eae2be.js +1 -0
  53. package/assets/esri/core/workers/chunks/e2ddfc96ddba92302e0c.js +1 -0
  54. package/assets/esri/core/workers/chunks/{61d3fcb419d6bf7e355e.js → e65ee26feca0564aeb9b.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{35cbf00f0c37a86517af.js → ed1de8b7406269e217b9.js} +1 -1
  56. package/assets/esri/core/workers/chunks/ed4ac5568dc2815b066d.js +1 -0
  57. package/assets/esri/core/workers/chunks/f029c12f1afee0e9b2a1.js +1 -0
  58. package/assets/esri/core/workers/chunks/{461c2de938bf4c9b1442.js → f6715b8765cd36d81ec8.js} +1 -1
  59. package/assets/esri/core/workers/chunks/f9a4f4efd63b8189a4eb.js +1 -0
  60. package/assets/esri/core/workers/chunks/{26a2d4b95cda0a41d980.js → fa1c58e5b582d61a03ab.js} +1 -1
  61. package/assets/esri/core/workers/chunks/fa377112ef3b78f6ed18.js +1 -0
  62. package/chunks/VolumeMask.glsl.js +3 -0
  63. package/chunks/persistableUrlUtils.js +1 -1
  64. package/config.js +1 -1
  65. package/core/Collection.d.ts +42 -6
  66. package/core/Collection.js +1 -1
  67. package/geometry/SpatialReference.d.ts +1 -4
  68. package/kernel.js +1 -1
  69. package/layers/BaseElevationLayer.js +1 -1
  70. package/layers/ElevationLayer.js +1 -1
  71. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  72. package/layers/KnowledgeGraphLayer.js +1 -1
  73. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  74. package/layers/StreamLayer.js +1 -1
  75. package/layers/VoxelWasmPerSceneView.js +1 -1
  76. package/layers/graphics/sources/connections/createConnection.js +1 -1
  77. package/layers/graphics/sources/parquet/ParquetFileStatistics.js +1 -1
  78. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  79. package/layers/graphics/sources/support/QueryTask.js +1 -1
  80. package/layers/mixins/SceneService.js +1 -1
  81. package/layers/raster/datasets/BaseRaster.js +1 -1
  82. package/layers/save/groupLayerUtils.js +1 -1
  83. package/layers/save/mediaLayerUtils.js +1 -1
  84. package/layers/support/ElevationQueryTileCache.js +1 -1
  85. package/layers/video/types.d.ts +17 -1
  86. package/linkChart/LinkChartProperties.js +1 -1
  87. package/package.json +1 -1
  88. package/portal/support/jsonContext.js +1 -1
  89. package/support/persistableUrlUtils.js +1 -1
  90. package/support/revision.js +1 -1
  91. package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +1 -1
  92. package/views/2d/layers/features/sources/strategies/FeatureHybridTileLoadStrategy.js +1 -1
  93. package/views/3d/GroundView3D.js +1 -1
  94. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  95. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  96. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  97. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  98. package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
  99. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  100. package/views/3d/support/gaussianSplatting/GaussianSplatHeaderTexture.js +1 -1
  101. package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
  102. package/views/3d/support/hitTest.js +1 -1
  103. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  104. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  105. package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
  106. package/views/3d/terrain/TerrainRenderer.js +1 -1
  107. package/views/3d/terrain/TerrainSurface.js +1 -1
  108. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
  109. package/views/3d/webgl-engine/collections/Component/ComponentObjectFixedBVH.js +1 -1
  110. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  111. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBufferFields.glsl.js +1 -1
  112. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMask.js +1 -1
  113. package/views/3d/webgl-engine/lib/CutFillVisualization.js +1 -1
  114. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  115. package/views/3d/webgl-engine/lib/IntersectorResult.js +1 -1
  116. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  117. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  118. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  119. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferFieldCreation.js +1 -1
  120. package/views/3d/webgl-engine/lib/lodRendering/LodResources.js +1 -1
  121. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  122. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  123. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  124. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  125. package/views/3d/webgl-engine/materials/intersectWithPolygonOffset.js +1 -1
  126. package/views/3d/webgl-engine/shaders/ShadowCastMaskTechnique.js +1 -1
  127. package/views/3d/webgl-engine/shaders/{CutFillMask.glsl.js → VolumeMask.glsl.js} +1 -1
  128. package/views/3d/webgl-engine/shaders/VolumeMaskTechnique.js +2 -0
  129. package/webdoc/support/resourceUtils.js +1 -1
  130. package/webdoc/support/types.d.ts +2 -0
  131. package/webdoc/support/utils.js +2 -0
  132. package/webdoc/support/webdocLoadUtils.js +1 -1
  133. package/webdoc/support/webdocSaveUtils.js +1 -1
  134. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  135. package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
  136. package/widgets/BatchAttributeForm/expressions/ArcadeExecutorProvider.js +1 -1
  137. package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
  138. package/widgets/BatchAttributeForm/expressions/ExpressionsModel.js +1 -1
  139. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  140. package/widgets/BatchAttributeForm/inputs/BatchFormInputs.js +1 -1
  141. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  142. package/widgets/BatchAttributeForm/inputs/RelationshipElementInput.js +1 -1
  143. package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
  144. package/widgets/BatchAttributeForm/rendered-content/RelationshipDetails.js +1 -1
  145. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  146. package/widgets/BatchAttributeForm.js +1 -1
  147. package/widgets/Editor/UpdateWorkflow.js +1 -1
  148. package/widgets/Editor.js +1 -1
  149. package/widgets/FeatureForm.js +1 -1
  150. package/widgets/FeatureTable/Grid/Column.d.ts +6 -0
  151. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  152. package/widgets/Sketch/SketchViewModel.js +1 -1
  153. package/widgets/support/SelectionList/FeatureItem.d.ts +116 -0
  154. package/widgets/support/SelectionList/GroupLayerItem.d.ts +94 -0
  155. package/widgets/support/SelectionList/ItemBase.d.ts +70 -0
  156. package/widgets/support/SelectionList/LayerItem.d.ts +140 -0
  157. package/widgets/support/SelectionList/LayerItem.js +1 -1
  158. package/widgets/support/SelectionList/SelectionListViewModel.d.ts +265 -0
  159. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  160. package/widgets/support/SelectionList/types.d.ts +42 -0
  161. package/widgets/support/forms/formUtils.js +1 -1
  162. package/assets/esri/core/workers/chunks/003a87b16f8a4b476e14.js +0 -1
  163. package/assets/esri/core/workers/chunks/0a50efb07eee36237e21.js +0 -1
  164. package/assets/esri/core/workers/chunks/129fdd1636e67997337c.js +0 -1
  165. package/assets/esri/core/workers/chunks/12e0c5b7cc5c3f9e6f0f.js +0 -1
  166. package/assets/esri/core/workers/chunks/147a89553188cc6aabf4.js +0 -1
  167. package/assets/esri/core/workers/chunks/26f1fd3f2be5102aae1d.js +0 -1
  168. package/assets/esri/core/workers/chunks/34fbeeeeef4bd01672c6.js +0 -1
  169. package/assets/esri/core/workers/chunks/36fe6adf6517d8f80125.js +0 -1
  170. package/assets/esri/core/workers/chunks/403f08e0c1a9203f7fba.js +0 -1
  171. package/assets/esri/core/workers/chunks/4f2170609742b51bd7b8.js +0 -1
  172. package/assets/esri/core/workers/chunks/5133083222588799493f.js +0 -1
  173. package/assets/esri/core/workers/chunks/52993a9dc0c56e9bda19.js +0 -1
  174. package/assets/esri/core/workers/chunks/5e35828216020f33e26b.js +0 -1
  175. package/assets/esri/core/workers/chunks/5f0d6c853873a7f32527.js +0 -1
  176. package/assets/esri/core/workers/chunks/6121cd0264b6841a5bac.js +0 -1
  177. package/assets/esri/core/workers/chunks/6823ba1688dfedba0107.js +0 -1
  178. package/assets/esri/core/workers/chunks/705d6b108fd121cea887.js +0 -1
  179. package/assets/esri/core/workers/chunks/73aa1bfa6e1dc271c9d7.js +0 -1
  180. package/assets/esri/core/workers/chunks/825eb845216762a1ed2f.js +0 -1
  181. package/assets/esri/core/workers/chunks/88df19742edb0cdc3e67.js +0 -1
  182. package/assets/esri/core/workers/chunks/8977c85aecc7e08ab13c.js +0 -1
  183. package/assets/esri/core/workers/chunks/8bdca809dd88eab9e5d8.js +0 -29
  184. package/assets/esri/core/workers/chunks/8c5726c7ce40a92901e6.js +0 -1
  185. package/assets/esri/core/workers/chunks/8c5e65982c3f9295e844.js +0 -1
  186. package/assets/esri/core/workers/chunks/8ce649e55fefc8eca55c.js +0 -1
  187. package/assets/esri/core/workers/chunks/90ae80b797642bff0efa.js +0 -1
  188. package/assets/esri/core/workers/chunks/97c758f736f28c5dab84.js +0 -1
  189. package/assets/esri/core/workers/chunks/a494abeb026d536d9fae.js +0 -1
  190. package/assets/esri/core/workers/chunks/a8ade34612e73862de6f.js +0 -1
  191. package/assets/esri/core/workers/chunks/a9d391071803b1e9e8a0.js +0 -1
  192. package/assets/esri/core/workers/chunks/aa3abc07de2921ef6ca1.js +0 -1
  193. package/assets/esri/core/workers/chunks/b03f09ee2224f0cc526a.js +0 -1
  194. package/assets/esri/core/workers/chunks/b3f1a442d6b7826e917f.js +0 -1
  195. package/assets/esri/core/workers/chunks/b819a9187426d0c146df.js +0 -1
  196. package/assets/esri/core/workers/chunks/f0225829f7d941914815.js +0 -1
  197. package/assets/esri/core/workers/chunks/fb34d6d96c8c0d53fcf6.js +0 -1
  198. package/chunks/CutFillMask.glsl.js +0 -3
  199. package/chunks/FocusAreaMask.glsl.js +0 -3
  200. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMask.glsl.js +0 -2
  201. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskTechnique.js +0 -2
  202. package/views/3d/webgl-engine/shaders/CutFillMaskTechnique.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{toConst as s}from"../../../../core/compilerUtils.js";import r from"../../../../core/Error.js";import i from"../../../../core/Handles.js";import has from"../../../../core/has.js";import a from"../../../../core/Logger.js";import{onAbortOrThrow as n,throwIfAborted as u}from"../../../../core/promiseUtils.js";import{QueueProcessor as o}from"../../../../core/QueueProcessor.js";import{parseWhereClause as l}from"../../../../core/sql.js";import c from"../../../../geometry/SpatialReference.js";import{set as p,create as d,expandWithAABB as f,expandWithRect as h,negativeInfinity as m}from"../../../../geometry/support/aaBoundingBox.js";import{copy as y,negativeInfinity as g,create as _,expandWithRect as w}from"../../../../geometry/support/aaBoundingRect.js";import{getScaleForResolution as x}from"../../../../geometry/support/scaleUtils.js";import{isWebMercator as F,isWGS84 as S}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertToGeometry as I}from"../../featureConversionUtils.js";import{getFieldNamesFromStatistics as v}from"../../data/attributeSupport.js";import{getQueryResultExtent as q,getQueryBoundingRects as R,QueryEngine as C}from"../../data/QueryEngine.js";import{queryCapabilities as b}from"../../data/QueryEngineCapabilities.js";import{QueryEngineResult as E}from"../../data/QueryEngineResult.js";import{normalizeQueryLike as O}from"../../data/queryUtils.js";import{createFileProvider as P}from"../parquet/createFileProvider.js";import{createDrawingInfo as M}from"./clientSideDefaults.js";import{getParquetFileId as T,getParquetRowId as j,getParquetObjectId as Q}from"./parquetIdUtils.js";import N from"../../../support/Field.js";import A from"../../../support/FieldsIndex.js";import{isNumericField as B}from"../../../support/fieldUtils.js";import{fromParquetGeometryEncodingJSON as G}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as D,fromParquetJSONGeometryType as z,toParquetJSONGeometryType as V}from"../../../support/parquetUtils.js";import{loadParquetModule as W}from"../../../../libs/parquet/loadParquetModule.js";import{FeatureStoreQueryAdapter as U}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as k}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as Z}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as J}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as L}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const H=new U,Y=4,X="__OBJECTID",$=new TextDecoder,K=8e3,ee=2e7,te=8,se=2,re=20;class ie{constructor(e,t){this._files=e,this._createFileStream=t,this._fileIndex=0,this._streamIndex=0,this._streams=[],this._pending=new Set,this._resolvedCount=0}async next(e){for(await this._fill(e);this._pending.size>0;){u(e),await this._fill(e);const t=await ae(this._pending);if(this._pending.delete(t.read),this._resolvedCount++,null!=t.chunk)return t.chunk}return null}async _fill(e){for(this._removeDone();this._pending.size<te;){const t=this._getOrCreateNextStream(e);if(null==t)return;this._pending.add(t.read(e))}}_getOrCreateNextStream(e){const t=this._resolvedCount>=te?te:se;if(this._fileIndex<this._files.length&&this._streams.length<t){const t=this._files[this._fileIndex++],s=new ne(t.id,this._createFileStream(t,e));return this._streams.push(s),s}return this._getNextStream()}_getNextStream(){const e=this._streams.length;for(let t=0;t<e;t++){const s=(this._streamIndex+t)%e,r=this._streams[s];if(r.canRead)return this._streamIndex=(s+1)%e,r}return null}_removeDone(){let e=this._streamIndex;for(let t=this._streams.length-1;t>=0;t--)this._streams[t].done&&(this._streams.splice(t,1),t<e&&e--);this._streamIndex=this._streams.length>0?e%this._streams.length:0}}function ae(e){return Promise.race(Array.from(e,async e=>({read:e,chunk:await e})))}class ne{constructor(e,t){this._fileId=e,this._stream=t,this._readCount=0,this._reachedEnd=!1}get canRead(){return!this._reachedEnd}get done(){return this._reachedEnd&&0===this._readCount}async read(e){this._readCount++;try{const t=await this._stream,s=await t.next(e);return null==s?(this._reachedEnd=!0,null):{fileId:this._fileId,chunk:s}}finally{this._readCount--}}}class ue{constructor(){this._hasZ=!1,this._hasM=!1,this._queue=new o({concurrency:Y,process:(e,t)=>this._executeQuery(e,t)}),this._streams=new Map,this._streamIdCounter=0,this._indexMap={},this._handles=new i}async load(e){const t=e.spatialReference?c.fromJSON(e.spatialReference):void 0;if(t&&!t.isWGS84&&!t.isWebMercator)throw new r("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");this._customParameters=e.customParameters,this._provider=P(e.provider,null,()=>this._customParameters),this._handles.add(this._provider.events.on("sourceChanged",async()=>{await this.reload(e),await this._source.onSourceChange()}));const s=await this._provider.getMetadata(),i=await D(s,{fields:e.fields?.map(e=>N.fromJSON(e)),geometryEncoding:e.geometryEncoding?G(e.geometryEncoding):null,geometryType:e.geometryType?z(e.geometryType):null,displayOptimization:e.displayOptimization,spatialReference:t});if(this._hasZ=!!s?.hasZ,this._hasM=!!s?.hasM,!i.fields)throw new r("parquet:unsupported","Fields must be defined");let n;if(i.spatialReference&&i.geometryType){if(!i.spatialReference)throw new r("parquet:unsupported","SpatialReference must be defined");if(!i.spatialReference.isGeographic&&!i.spatialReference.isWebMercator)throw new r("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");i.spatialReference.isGeographic&&!i.spatialReference.isWGS84&&(a.getLogger("parquet:unsupported-projection").warn("Found a geographic projection that is not WGS84. Handling as WGS84.",{spatialReference:i.spatialReference}),i.spatialReference=c.WGS84),n={geometry:i.geometryEncoding?{geometryType:V(i.geometryType),spatialReference:i.spatialReference.toJSON(),encoding:i.geometryEncoding.toJSON()}:null,displayOptimization:i.displayOptimization}}this.setCustomParameters(e.customParameters),this._displayOptimization=i.displayOptimization,await this._provider.updateGeometryInfo(n),this._capabilities=Ee(await this._getFileStatistics(),this._hasZ,this._hasM);const u=await this._provider.getFiles();if(!u.length)return{layerDefinition:{},capabilities:Ee(null,this._hasZ,this._hasM)};const o=await u[0].file;i.file=o;const{fields:l}=i;if(null==l)throw new r("parquet-layer:missing-metadata","Unable to create parquet source: cannot infer fields",l);l.push(new N({name:X,type:"oid",alias:X}));for(const r of l){const e=o.getColumnId(r.name);null!=e&&(this._indexMap[r.name]=e)}const p=new A(l.map(e=>e.toJSON()));this._fieldsIndex=p;const d=V(i.geometryType??"point");return this._metadata=J.createFeature({fieldsIndex:p.toJSON(),geometryType:d,hasZ:this._hasZ,hasM:this._hasM,featureIdInfo:{type:"object-id",fieldName:X},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:i.spatialReference,outSpatialReference:null,attributeSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:d,featureIdInfo:{type:"object-id",fieldName:X},hasM:this._hasM,hasZ:this._hasZ,spatialReference:i.spatialReference?.toJSON()??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},this._fullExtent=s?.extent?s.extent:await this._tryDeriveParquetFullExtent(i),{capabilities:this._capabilities,layerDefinition:{fields:i.fields?.map(e=>e.toJSON()),drawingInfo:M(d),extent:this._fullExtent??void 0,geometryType:d,geometryEncoding:i.geometryEncoding?.toJSON(),displayOptimization:i.displayOptimization}}}destroy(){this._provider.destroy(),this._queue.destroy();for(const{handle:e}of this._streams.values())e.remove();this._streams.clear(),this._indexMap={},this._handles.removeAll()}async reload(e){this.destroy(),await this.load(e)}set remoteClient(e){this._source=e.createInvokeProxy("")}setCustomParameters(e){this._customParameters=e}getIndexMap(){return this._indexMap}async updateFileProvider(e){this._provider=P(e,this._provider.getGeometryInfo(),()=>this._customParameters)}async queryFeatures(e,t){const s=await O(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),Oe(s)||(s.resultRecordCount=s.resultRecordCount?Math.min(s.resultRecordCount,K):K,s.resultOffset=s.resultOffset??0),s.outStatistics)return this._queryStatistics(s,t);s.returnDistinctValues&&(s.returnGeometry=void 0);return(await this._enqueueQuery(s,t)).createQueryResponse()}async queryFeatureCount(e,t){const s=await O(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),!pe(s))return this._getFeatureCount();s.outFields=void 0,s.returnGeometry=void 0;return(await this._enqueueQuery(s,t)).createQueryResponseForCount()}async queryObjectIds(e,t){const s=await O(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),!pe(s))return Array.from({length:await this._getFeatureCount()},(e,t)=>t);s.resultRecordCount=s.resultRecordCount?Math.min(s.resultRecordCount,8e3):8e3,s.resultOffset=s.resultOffset??0,s.returnGeometry=void 0,s.outFields=void 0;return(await this._enqueueQuery(s,t)).items.map(e=>e.getObjectId())}async queryAttributeBins(e,t={}){throw new r("parquet:unsupported","queryAttributeBins not supported.")}async queryExtent(e,t){const r=await O(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),this._fullExtent&&!pe(r))return{count:await this._getFeatureCount(),extent:this._fullExtent};const i=s(this._metadata.spatialReference);r.returnGeometry=!0,r.outFields=void 0;const a=p(d(),m),n=d(),u=await this._enqueueQuery(r,t);let o=0;for(const s of u.items)s.getBounds(n)&&(f(a,n),o+=1);return{count:o,extent:q(a,i,r.outSR?s(r.outSR):i.toJSON(),i,!1)}}async queryStream(e,t){if(!t.signal)throw new Error("InternalError: AbortSignal must be passed");const s=await this._getCandidateFiles(e),r=new ie(s,async(t,s)=>{const r=await t.file,i=await this._createParquetDisplayQuery(r,t.id,e);return r.executeQuery(i,K,s)}),i=this._streamIdCounter++,a=n(t.signal,e=>{const t=this._streams.get(i);null!=t&&(t.handle.remove(),this._streams.delete(i))});return this._streams.set(i,{stream:r,handle:a}),i}async getStreamNext(e,t){if(!t.signal)throw new Error("InternalError: AbortSignal must be passed");const s=this._streams.get(e);if(!s)return{result:null};const r=await s.stream.next(t.signal);if(null==r)return s.handle.remove(),this._streams.delete(e),{result:null};const i=r.chunk.serialize().buffer,a={fileId:r.fileId,buffer:i};return i instanceof ArrayBuffer?{result:a,transferList:[i]}:{result:a}}async getStreamNextFeatures(e,t){const{result:s}=await this.getStreamNext(e,t);if(null==s)return null;const r=(await W()).ParquetChunk.deserialize(new Uint8Array(s.buffer)),i=new L(this._metadata,this._indexMap,r,s.fileId),a=[];for(;i.next();){const e=I(i.readGeometryWorldSpace(),i.geometryType,i.hasZ,i.hasM),t=i.readAttributes();a.push({attributes:t,geometry:e})}return{features:a}}async createPatch(e,t,s,r,i){if(!i.signal)throw new Error("InternalError: AbortSignal must be passed");const a=await this._getFileInfoById(e),n=await a.file;return(await n.createChunkPatch(t,s,r,i.signal)).serialize().buffer}async _getCandidateFiles(e){const t=await this._provider.getFiles(),s=await this._getSpatialFilePruning(e);if(null==s)return t;const r=t.filter(e=>this._mayIncludeFileForSpatialPruning(e,s));return"xz"===s.type?Ie(r,s):r}async _queryStatistics(e,t){const s=await O({...e},null,this._queryEngineParams.spatialReference);if(s.returnGeometry=void 0,he(s,this._fieldsIndex)){const e=await this._getStatisticsFromFiles(s);if(e)return e}return(await this._enqueueQuery(s,t)).createQueryResponse()}async _getStatisticsFromFiles(e){const t=await this._provider.getFiles(),s={},r=[];for(const i of e.outStatistics??[]){const e=ge(i,t);if(!e.available)return null;s[i.outStatisticFieldName]=e.value,r.push(ye(i,this._fieldsIndex))}return{fields:r,features:[{attributes:s}]}}async _getSpatialFilePruning(e){if("tile"!==e.type&&("arcade"!==e.type||null==e.extent))return null;const t=this._displayOptimization,s=t?.index;if(null==s)return null;const r=e.outSpatialReference.wkid;if(null==s.wkid||null==r)return null;const i=s.wkid,a=await W();switch(s.type){case"xz":return{type:"xz",fieldName:s.code,intersects:(t,n)=>a.queryIntersectsXZStatistics(s.fullExtent,e.extent,r,i,re,t,n)};case"z":return{type:"xy",xFieldName:s.xColumn,yFieldName:s.yColumn,intersects:(t,s,n,u)=>a.queryIntersectsXYStatistics(e.extent,r,i,t,s,n,u)}}}_mayIncludeFileForSpatialPruning(e,t){switch(t.type){case"xz":{const s=Se(e,t);return null==s||Re(s,t)}case"xy":{const{xStatistics:s,yStatistics:r}=qe(e,t);return null==s||null==r||Ce(s,r,t)}}}async _tryDeriveParquetFullExtent(s){if(!s.spatialReference)return null;if(null==this._fullExtent&&"location"===s.geometryEncoding?.type){const i=await this._provider.getFiles(),{xField:a,yField:n}=s.geometryEncoding,u=p(d(),m);for(const s of i){const i=await s.file;for(const s of i.rowGroups()){const i={stack:[],error:void 0,hasError:!1};try{const t=e(i,s.columnDescriptorForAttribute(a),!1),r=e(i,s.columnDescriptorForAttribute(n),!1),o=[t.minValue(),r.minValue(),t.maxValue(),r.maxValue()];h(u,o),s.free()}catch(r){i.error=r,i.hasError=!0}finally{t(i)}}}return{xmin:u[0],ymin:u[1],xmax:u[3],ymax:u[4],spatialReference:s.spatialReference?.toJSON()}}return null}async _getFileInfoById(e){const t=await this._provider.getFiles();for(const s of t)if(s.id===e)return s;throw new Error(`InternalError: File ${e} does not exist`)}async _getFileStatistics(){return{featureCount:await this._getFeatureCount(),byteLength:await this._getByteLength()}}async _getFile(e){return(await this._getFileInfoById(e)).file}async _createParquetQuery(e,t,s,r,i){const a=(await W()).Query.new();null!=s&&a.setPreFilterStart(s),null!=r&&a.setPreFilterCount(r),null!=i&&a.setPostFilterCount(i);const n=await this._getRequiredFields(e);a.setOutFields(n),(e.geometry||e.returnGeometry)&&a.setReturnGeometry(!0),a.setReturnZ(!!e.returnZ),a.setReturnM(!!e.returnM);const u=this._tryGetGeneralizedGeometryScale(e);null!=u&&a.setScale(u);const o=e.geometry?.spatialReference??this._queryEngineParams.spatialReference,l=o.wkid;if(e.geometry&&(F(o)||S(o))){const t=y(_(),g);for(const s of R(e.geometry))w(t,s);a.setOutSpatialReference(l),a.setExtent({xmin:t[0],ymin:t[1],xmax:t[2],ymax:t[3]})}if(e.where){const{id:s,file:r}=t;await this._setWhereClause(a,await r,s,e.where)}return a}async _createParquetDisplayQuery(e,t,s){const r=(await W()).Query.new();return"tile"===s.type?(r.setExtent(s.extent),r.setQuantizationTransform(s.transform),r.setScale(s.scale)):"arcade"===s.type&&null!=s.extent&&r.setExtent(s.extent),r.setOutFields(s.outFields.filter(e=>null!=this._indexMap[e])),r.setOutSpatialReference(s.outSpatialReference.wkid),r.setReturnGeometry(s.returnGeometry),r.setReturnZ(s.returnZ),r.setReturnM(s.returnM),s.where&&await this._setWhereClause(r,e,t,s.where),r}async _getFeatureCount(){return(await this._provider.getFiles()).map(e=>e.statistics.rowCount).reduce((e,t)=>e+t,0)}async _getByteLength(){return(await this._provider.getFiles()).map(e=>e.statistics.byteSize).reduce((e,t)=>e+t,0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new r("parquet:unsupported","Statistics queries are not supported",{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new r("parquet:unsupported","Queries using orderBy are not supported",{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new r("parquet:unsupported","Queries using returnDistinctValues are not supported",{query:e})}async _setWhereClause(e,t,s,i){const a=this._indexMap,n=this._fieldsIndex,u={getAttribute(e,r){const i=a[r];if(null==i){const t=n.get(r);if("__OBJECTID"===t?.name){const t=e.row+e.rowGroupStart;return Q(s,t)}return null}const u=t.readAttribute(e.rowGroup,e.row,i);if(null==u)return null;const o=n.get(r);return"esriFieldTypeString"===o.type||"esriFieldTypeDateOnly"===o.type||"esriFieldTypeTimeOnly"===o.type||"esriFieldTypeTimestampOffset"===o.type?$.decode(u):u}},o=await l(i,this._fieldsIndex);if(!o.isStandardized)throw new r("sql-parse-error","expression is not standardized");const c=(e,t,s)=>o.testFeatureCompiled({rowGroup:e,row:t,rowGroupStart:s},u,null),p=o.fieldNames.map(e=>n.get(e)).filter(e=>e&&null!=this._indexMap[e?.name]);e.setWhere(i),e.setWhereEvaluator(c),e.setWhereFields(p.map(e=>e.name))}async*_streamFeatures(e,t,s,r,i){const a=await this._provider.getFiles();let n=0;for(const u of a){const a=n,o=n+u.statistics.rowCount;if(n+=u.statistics.rowCount,null!=t&&t>=o)continue;const l=null!=t?Math.max(t-a,0):null;let c=s;if(null!=s){const e=t??0,r=e+s,i=Math.max(e,a),n=Math.min(r,o);c=Math.max(n-i,0)}if(0===c)continue;const p=await this._createParquetQuery(e,u,l,c,r),d=await u.file,f=await d.executeQuery(p,K),h=async()=>{const e=await f.next(i);if(!e)return null;const t=new L(this._metadata,this._indexMap,e,u.id);return Fe([new k(t,null,0,!1)],this._queryEngineParams)};let m=await h();for(;null!=m;)yield m,m=await h()}}async _queryFeaturesWithQueryEnginePagination(e,t){const s=[],r=this._streamFeatures(e,null,null,null,t);let i=await r.next();for(;!i.done;){const a=await i.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(const e of a)s.push(e);i=await r.next()}return s}async _queryFeaturesWithUpfrontPagination(e,t){let s,r,i,a=e.resultOffset??0,n=e.resultRecordCount??K;de(e)?fe(e)||(i=a+n):(a&&(s=a,a=0),r=e.resultRecordCount);const u=[],o=this._streamFeatures(e,s,r,i,t);let l=await o.next();for(;!l.done&&n>0;){const s=await l.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(const e of s)if(a>0)a--;else if(u.push(e),--n<=0)return u;l=await o.next()}return u}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){if(e.objectIds?.length){const s=new Map;for(const t of e.objectIds){const e=T(t),r=j(t);let i=s.get(e);i||(i=[],s.set(e,i)),i.push(r)}const r=[];for(const[i,a]of s.entries()){const s=await this._executeFileIdQuery(e,i,a,t);for(const e of s)r.push(e)}return new E(r,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:this._hasM,hasZ:this._hasZ,featureAdapter:H,featureIdInfo:this._queryEngineParams.featureIdInfo})}if("1=1"===e.where&&(e.where=null),e.resultOffset??=0,e.resultRecordCount??=await this._getFeatureCount(),e.resultRecordCount>ee){if(!(this._displayOptimization&&e.geometry))throw new r("parquet:cannot-execute-query","Unable to execute query, dataset is too large.")}const s=!!e.orderByFields?.length||!!e.outStatistics?.length||!!e.returnDistinctValues,i=s?await this._queryFeaturesWithQueryEnginePagination(e,t):await this._queryFeaturesWithUpfrontPagination(e,t);return s||(e.resultOffset=0),new E(i,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:this._hasM,hasZ:this._hasZ,featureAdapter:H,featureIdInfo:this._queryEngineParams.featureIdInfo})}async _executeFileIdQuery(e,t,s,r){const i=await this._getRequiredFields(e),a=(await W()).Query.new();a.setOutFields(i),a.setReturnGeometry(!!e.returnGeometry),a.setReturnZ(!!e.returnZ),a.setReturnM(!!e.returnM),a.setIds(new Uint32Array(s));const n=await this._getFile(t),u=await n.executeQuery(a,K,r);let o=await u.next(r),l=0;const c=[];for(;null!=o;){const e=new L(this._metadata,this._indexMap,o,t),s=new k(e,null,l++,!1);c.push(s),o=await u.next(r)}return Fe(c,this._queryEngineParams).executeQueryForOpaqueFeatures(e,r)}async _getRequiredFields(e){const t=new Set;if(e.outStatistics)for(const s of v(this._fieldsIndex,e.outStatistics,e.groupByFieldsForStatistics))t.add(s);else if(e.outFields)for(const s of e.outFields)t.add(s);return(t.has("*")?this._fieldsIndex.fields.map(e=>e.name):Array.from(t)).filter(e=>null!=this._indexMap[e])}_tryGetGeneralizedGeometryScale(e){if(!this._displayOptimization)return null;const t=e.outSR??this._queryEngineParams.spatialReference;if(!F(t)&&!S(t))return null;const s=e.quantizationParameters?.tolerance??e.maxAllowableOffset;return s?x(s,t):null}}function oe(e){switch(e){case"fullText":case"having":case"timeExtent":case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"geometry":case"resultOffset":case"resultRecordCount":return!0;default:return!1}}function le(e){switch(e){case"fullText":case"having":case"timeExtent":case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"geometry":return!0;default:return!1}}function ce(e){switch(e){case"fullText":case"having":case"timeExtent":return!0;case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"resultOffset":case"geometry":case"resultRecordCount":return!1}return!1}function pe(e){for(const t in e){const s=t;if(oe(s)&&null!==e[s])return!0}return!1}function de(e){for(const t in e){const s=t;if(le(s)&&null!==e[s])return!0}return!1}function fe(e){for(const t in e){const s=t;if(ce(s)&&null!==e[s])return!0}return!1}function he(e,t){return!!e.outStatistics?.length&&!pe(e)&&!e.groupByFieldsForStatistics?.length&&!e.orderByFields?.length&&!e.returnDistinctValues&&!e.returnAggIds&&e.outStatistics.every(e=>me(e,t))}function me(e,t){switch(e.statisticType){case"count":return"1"===e.onStatisticField||null!=t.get(e.onStatisticField);case"min":case"max":{const s=t.get(e.onStatisticField);return null!=s&&B(s)}default:return!1}}function ye(e,t){const s="exceedslimit"!==e.statisticType?t.get(e.onStatisticField):null,r="min"!==e.statisticType&&"max"!==e.statisticType||"esriFieldTypeDate"!==s?.type?"esriFieldTypeDouble":s.type;return{name:e.outStatisticFieldName,alias:e.outStatisticFieldName,type:r}}function ge(e,t){switch(e.statisticType){case"count":return _e(e,t);case"min":return we(e,t,Math.min);case"max":return we(e,t,Math.max);default:return{available:!1,value:null}}}function _e(e,t){if("count"!==e.statisticType)return{available:!1,value:null};if("1"===e.onStatisticField)return{available:!0,value:t.reduce((e,t)=>e+t.statistics.rowCount,0)};let s=0;for(const r of t){const t=r.statistics.statistics.get(e.onStatisticField);if(null==t||null==t.nullCount)return{available:!1,value:null};s+=r.statistics.rowCount-t.nullCount}return{available:!0,value:s}}function we(e,t,s){if("min"!==e.statisticType&&"max"!==e.statisticType)return{available:!1,value:null};let r=null;const i="min"===e.statisticType?"minValue":"maxValue";for(const a of t){const t=a.statistics.statistics.get(e.onStatisticField);if(null==t)return{available:!1,value:null};const n=xe(t[i]);null!=n&&(r=null==r?n:s(r,n))}return{available:!0,value:r}}function xe(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function Fe(e,t){const s=new Z;for(const r of e)s.insert(r);return new C({...t,featureStore:s})}function Se(e,t){return e.statistics.statistics.get(t.fieldName)??null}function Ie(e,t){return e.slice().sort((e,s)=>{const r=ve(e,t),i=ve(s,t);return r===i?0:r<i?-1:1})}function ve(e,t){const s=Se(e,t);if(null==s)return Number.POSITIVE_INFINITY;const r=be(s.minValue),i=be(s.maxValue);return null==r||null==i||i<r?Number.POSITIVE_INFINITY:i-r}function qe(e,t){return{xStatistics:e.statistics.statistics.get(t.xFieldName)??null,yStatistics:e.statistics.statistics.get(t.yFieldName)??null}}function Re(e,t){const s=be(e.minValue),r=be(e.maxValue);return null==s||null==r||t.intersects(s,r)}function Ce(e,t,s){const r=be(e.minValue),i=be(e.maxValue),a=be(t.minValue),n=be(t.maxValue);return null==r||null==i||null==a||null==n||s.intersects(r,i,a,n)}function be(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function Ee(e,t,s){const r=e?.featureCount;let i=!1;return null!=r&&r<has("parquetlayer-full-query-feature-count")&&(i=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:s,supportsTrueCurve:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{...b,maxRecordCount:K,supportsOrderBy:i,supportsDistinct:!0,supportsStatistics:!0,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1}},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsTrueCurveUpdate:!1,supportsTrueCurveUpdateByTrueCurveClientsOnly:!0,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function Oe(e){return!!(e.objectIds?.length||e.outStatistics||e.orderByFields?.length||e.returnDistinctValues)}export{ue as default};
2
+ import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{toConst as s}from"../../../../core/compilerUtils.js";import r from"../../../../core/Error.js";import i from"../../../../core/Handles.js";import has from"../../../../core/has.js";import a from"../../../../core/Logger.js";import{onAbortOrThrow as n,throwIfAborted as u}from"../../../../core/promiseUtils.js";import{QueueProcessor as o}from"../../../../core/QueueProcessor.js";import{parseWhereClause as l}from"../../../../core/sql.js";import c from"../../../../geometry/SpatialReference.js";import{set as p,create as d,expandWithAABB as f,expandWithRect as h,negativeInfinity as m}from"../../../../geometry/support/aaBoundingBox.js";import{copy as y,negativeInfinity as g,create as _,expandWithRect as w}from"../../../../geometry/support/aaBoundingRect.js";import{getScaleForResolution as x}from"../../../../geometry/support/scaleUtils.js";import{isWebMercator as F,isWGS84 as S}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertToGeometry as I}from"../../featureConversionUtils.js";import{getFieldNamesFromStatistics as v}from"../../data/attributeSupport.js";import{getQueryResultExtent as q,getQueryBoundingRects as R,QueryEngine as b}from"../../data/QueryEngine.js";import{queryCapabilities as C}from"../../data/QueryEngineCapabilities.js";import{QueryEngineResult as E}from"../../data/QueryEngineResult.js";import{normalizeQueryLike as O}from"../../data/queryUtils.js";import{createFileProvider as P}from"../parquet/createFileProvider.js";import{readFieldStatistic as M}from"../parquet/ParquetFileStatistics.js";import{createDrawingInfo as T}from"./clientSideDefaults.js";import{getParquetFileId as j,getParquetRowId as Q,getParquetObjectId as A}from"./parquetIdUtils.js";import B from"../../../support/Field.js";import G from"../../../support/FieldsIndex.js";import{isNumericField as N}from"../../../support/fieldUtils.js";import{fromParquetGeometryEncodingJSON as D}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as z,fromParquetJSONGeometryType as V,toParquetJSONGeometryType as k}from"../../../support/parquetUtils.js";import{loadParquetModule as W}from"../../../../libs/parquet/loadParquetModule.js";import{FeatureStoreQueryAdapter as U}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as Z}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as J}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as L}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as H}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const X=new U,Y=4,$="__OBJECTID",K=new TextDecoder,ee=8e3,te=2e7,se=8,re=2,ie=20;class ae{constructor(e,t){this._files=e,this._createFileStream=t,this._fileIndex=0,this._streamIndex=0,this._streams=[],this._pending=new Set,this._resolvedCount=0}async next(e){for(await this._fill(e);this._pending.size>0;){u(e),await this._fill(e);const t=await ne(this._pending);if(this._pending.delete(t.read),this._resolvedCount++,null!=t.chunk)return t.chunk}return null}async _fill(e){for(this._removeDone();this._pending.size<se;){const t=this._getOrCreateNextStream(e);if(null==t)return;this._pending.add(t.read(e))}}_getOrCreateNextStream(e){const t=this._resolvedCount>=se?se:re;if(this._fileIndex<this._files.length&&this._streams.length<t){const t=this._files[this._fileIndex++],s=new ue(t.id,this._createFileStream(t,e));return this._streams.push(s),s}return this._getNextStream()}_getNextStream(){const e=this._streams.length;for(let t=0;t<e;t++){const s=(this._streamIndex+t)%e,r=this._streams[s];if(r.canRead)return this._streamIndex=(s+1)%e,r}return null}_removeDone(){let e=this._streamIndex;for(let t=this._streams.length-1;t>=0;t--)this._streams[t].done&&(this._streams.splice(t,1),t<e&&e--);this._streamIndex=this._streams.length>0?e%this._streams.length:0}}function ne(e){return Promise.race(Array.from(e,async e=>({read:e,chunk:await e})))}class ue{constructor(e,t){this._fileId=e,this._stream=t,this._readCount=0,this._reachedEnd=!1}get canRead(){return!this._reachedEnd}get done(){return this._reachedEnd&&0===this._readCount}async read(e){this._readCount++;try{const t=await this._stream,s=await t.next(e);return null==s?(this._reachedEnd=!0,null):{fileId:this._fileId,chunk:s}}finally{this._readCount--}}}class oe{constructor(){this._hasZ=!1,this._hasM=!1,this._queue=new o({concurrency:Y,process:(e,t)=>this._executeQuery(e,t)}),this._streams=new Map,this._streamIdCounter=0,this._indexMap={},this._handles=new i}async load(e){const t=e.spatialReference?c.fromJSON(e.spatialReference):void 0;if(t&&!t.isWGS84&&!t.isWebMercator)throw new r("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");this._customParameters=e.customParameters,this._provider=P(e.provider,null,()=>this._customParameters),this._handles.add(this._provider.events.on("sourceChanged",async()=>{await this.reload(e),await this._source.onSourceChange()}));const s=await this._provider.getMetadata(),i=await z(s,{fields:e.fields?.map(e=>B.fromJSON(e)),geometryEncoding:e.geometryEncoding?D(e.geometryEncoding):null,geometryType:e.geometryType?V(e.geometryType):null,displayOptimization:e.displayOptimization,spatialReference:t});if(this._hasZ=!!s?.hasZ,this._hasM=!!s?.hasM,!i.fields)throw new r("parquet:unsupported","Fields must be defined");let n;if(i.spatialReference&&i.geometryType){if(!i.spatialReference)throw new r("parquet:unsupported","SpatialReference must be defined");if(!i.spatialReference.isGeographic&&!i.spatialReference.isWebMercator)throw new r("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");i.spatialReference.isGeographic&&!i.spatialReference.isWGS84&&(a.getLogger("parquet:unsupported-projection").warn("Found a geographic projection that is not WGS84. Handling as WGS84.",{spatialReference:i.spatialReference}),i.spatialReference=c.WGS84),n={geometry:i.geometryEncoding?{geometryType:k(i.geometryType),spatialReference:i.spatialReference.toJSON(),encoding:i.geometryEncoding.toJSON()}:null,displayOptimization:i.displayOptimization}}this.setCustomParameters(e.customParameters),this._displayOptimization=i.displayOptimization,await this._provider.updateGeometryInfo(n),this._capabilities=Re(await this._getFileStatistics(),this._hasZ,this._hasM);const u=await this._provider.getFiles();if(!u.length)return{layerDefinition:{},capabilities:Re(null,this._hasZ,this._hasM)};const o=await u[0].file;i.file=o;const{fields:l}=i;if(null==l)throw new r("parquet-layer:missing-metadata","Unable to create parquet source: cannot infer fields",l);l.push(new B({name:$,type:"oid",alias:$}));for(const r of l){const e=o.getColumnId(r.name);null!=e&&(this._indexMap[r.name]=e)}const p=new G(l.map(e=>e.toJSON()));this._fieldsIndex=p;const d=k(i.geometryType??"point");return this._metadata=L.createFeature({fieldsIndex:p.toJSON(),geometryType:d,hasZ:this._hasZ,hasM:this._hasM,featureIdInfo:{type:"object-id",fieldName:$},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:i.spatialReference,outSpatialReference:null,attributeSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:d,featureIdInfo:{type:"object-id",fieldName:$},hasM:this._hasM,hasZ:this._hasZ,spatialReference:i.spatialReference?.toJSON()??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},this._fullExtent=s?.extent?s.extent:await this._tryDeriveParquetFullExtent(i),{capabilities:this._capabilities,layerDefinition:{fields:i.fields?.map(e=>e.toJSON()),drawingInfo:T(d),extent:this._fullExtent??void 0,geometryType:d,geometryEncoding:i.geometryEncoding?.toJSON(),displayOptimization:i.displayOptimization}}}destroy(){this._provider.destroy(),this._queue.destroy();for(const{handle:e}of this._streams.values())e.remove();this._streams.clear(),this._indexMap={},this._handles.removeAll()}async reload(e){this.destroy(),await this.load(e)}set remoteClient(e){this._source=e.createInvokeProxy("")}setCustomParameters(e){this._customParameters=e}getIndexMap(){return this._indexMap}async updateFileProvider(e){this._provider=P(e,this._provider.getGeometryInfo(),()=>this._customParameters)}async queryFeatures(e,t){const s=await O(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),be(s)||(s.resultRecordCount=s.resultRecordCount?Math.min(s.resultRecordCount,ee):ee,s.resultOffset=s.resultOffset??0),s.outStatistics)return this._queryStatistics(s,t);s.returnDistinctValues&&(s.returnGeometry=void 0);return(await this._enqueueQuery(s,t)).createQueryResponse()}async queryFeatureCount(e,t){const s=await O(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),!de(s))return this._getFeatureCount();s.outFields=void 0,s.returnGeometry=void 0;return(await this._enqueueQuery(s,t)).createQueryResponseForCount()}async queryObjectIds(e,t){const s=await O(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),!de(s))return Array.from({length:await this._getFeatureCount()},(e,t)=>t);s.resultRecordCount=s.resultRecordCount?Math.min(s.resultRecordCount,8e3):8e3,s.resultOffset=s.resultOffset??0,s.returnGeometry=void 0,s.outFields=void 0;return(await this._enqueueQuery(s,t)).items.map(e=>e.getObjectId())}async queryAttributeBins(e,t={}){throw new r("parquet:unsupported","queryAttributeBins not supported.")}async queryExtent(e,t){const r=await O(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),this._fullExtent&&!de(r))return{count:await this._getFeatureCount(),extent:this._fullExtent};const i=s(this._metadata.spatialReference);r.returnGeometry=!0,r.outFields=void 0;const a=p(d(),m),n=d(),u=await this._enqueueQuery(r,t);let o=0;for(const s of u.items)s.getBounds(n)&&(f(a,n),o+=1);return{count:o,extent:q(a,i,r.outSR?s(r.outSR):i.toJSON(),i,!1)}}async queryStream(e,t){if(!t.signal)throw new Error("InternalError: AbortSignal must be passed");const s=await this._getCandidateFiles(e),r=new ae(s,async(t,s)=>{const r=await t.file,i=await this._createParquetDisplayQuery(r,t.id,e);return r.executeQuery(i,ee,s)}),i=this._streamIdCounter++,a=n(t.signal,e=>{const t=this._streams.get(i);null!=t&&(t.handle.remove(),this._streams.delete(i))});return this._streams.set(i,{stream:r,handle:a}),i}async getStreamNext(e,t){if(!t.signal)throw new Error("InternalError: AbortSignal must be passed");const s=this._streams.get(e);if(!s)return{result:null};const r=await s.stream.next(t.signal);if(null==r)return s.handle.remove(),this._streams.delete(e),{result:null};const i=r.chunk.serialize().buffer,a={fileId:r.fileId,buffer:i};return i instanceof ArrayBuffer?{result:a,transferList:[i]}:{result:a}}async getStreamNextFeatures(e,t){const{result:s}=await this.getStreamNext(e,t);if(null==s)return null;const r=(await W()).ParquetChunk.deserialize(new Uint8Array(s.buffer)),i=new H(this._metadata,this._indexMap,r,s.fileId),a=[];for(;i.next();){const e=I(i.readGeometryWorldSpace(),i.geometryType,i.hasZ,i.hasM),t=i.readAttributes();a.push({attributes:t,geometry:e})}return{features:a}}async createPatch(e,t,s,r,i){if(!i.signal)throw new Error("InternalError: AbortSignal must be passed");const a=await this._getFileInfoById(e),n=await a.file;return(await n.createChunkPatch(t,s,r,i.signal)).serialize().buffer}async _getCandidateFiles(e){const t=await this._provider.getFiles(),s=await this._getSpatialFilePruning(e);if(null==s)return t;const r=t.filter(e=>this._mayIncludeFileForSpatialPruning(e,s));return"xz"===s.type?ve(r,s):r}async _queryStatistics(e,t){const s=await O({...e},null,this._queryEngineParams.spatialReference);if(s.returnGeometry=void 0,me(s,this._fieldsIndex)){const e=await this._getStatisticsFromFiles(s);if(e)return e}return(await this._enqueueQuery(s,t)).createQueryResponse()}async _getStatisticsFromFiles(e){const t=await this._provider.getFiles(),s={},r=[];for(const i of e.outStatistics??[]){const e=_e(i,t);if(!e.available)return null;s[i.outStatisticFieldName]=e.value,r.push(ge(i,this._fieldsIndex))}return{fields:r,features:[{attributes:s}]}}async _getSpatialFilePruning(e){if("tile"!==e.type&&("arcade"!==e.type||null==e.extent))return null;const t=this._displayOptimization,s=t?.index;if(null==s)return null;const r=e.outSpatialReference.wkid;if(null==s.wkid||null==r)return null;const i=s.wkid,a=await W();switch(s.type){case"xz":return{type:"xz",fieldName:s.code,intersects:(t,n)=>a.queryIntersectsXZStatistics(s.fullExtent,e.extent,r,i,ie,t,n)};case"z":return{type:"xy",xFieldName:s.xColumn,yFieldName:s.yColumn,intersects:(t,s,n,u)=>a.queryIntersectsXYStatistics(e.extent,r,i,t,s,n,u)}}}_mayIncludeFileForSpatialPruning(e,t){switch(t.type){case"xz":{const s=Ie(e,t);return"null-only"!==s?.type&&("bounds"!==s?.type||t.intersects(s.minValue,s.maxValue))}case"xy":{const s=e.statistics.statistics.get(t.xFieldName),r=e.statistics.statistics.get(t.yFieldName);return"null-only"!==s?.type&&"null-only"!==r?.type&&("bounds"!==s?.type||"bounds"!==r?.type||t.intersects(s.minValue,s.maxValue,r.minValue,r.maxValue))}}}async _tryDeriveParquetFullExtent(s){if(!s.spatialReference)return null;if(null==this._fullExtent&&"location"===s.geometryEncoding?.type){const i=await this._provider.getFiles(),{xField:a,yField:n}=s.geometryEncoding,u=p(d(),m);let o=!1;for(const s of i){const i=await s.file;for(const s of i.rowGroups()){const i={stack:[],error:void 0,hasError:!1};try{const t=e(i,s.columnDescriptorForAttribute(a),!1),r=e(i,s.columnDescriptorForAttribute(n),!1),l=M(t),c=M(r);if("bounds"===l?.type&&"bounds"===c?.type){const e=[l.minValue,c.minValue,l.maxValue,c.maxValue];h(u,e),o=!0}s.free()}catch(r){i.error=r,i.hasError=!0}finally{t(i)}}}return o?{xmin:u[0],ymin:u[1],xmax:u[3],ymax:u[4],spatialReference:s.spatialReference?.toJSON()}:null}return null}async _getFileInfoById(e){const t=await this._provider.getFiles();for(const s of t)if(s.id===e)return s;throw new Error(`InternalError: File ${e} does not exist`)}async _getFileStatistics(){return{featureCount:await this._getFeatureCount(),byteLength:await this._getByteLength()}}async _getFile(e){return(await this._getFileInfoById(e)).file}async _createParquetQuery(e,t,s,r,i){const a=(await W()).Query.new();null!=s&&a.setPreFilterStart(s),null!=r&&a.setPreFilterCount(r),null!=i&&a.setPostFilterCount(i);const n=await this._getRequiredFields(e);a.setOutFields(n),(e.geometry||e.returnGeometry)&&a.setReturnGeometry(!0),a.setReturnZ(!!e.returnZ),a.setReturnM(!!e.returnM);const u=this._tryGetGeneralizedGeometryScale(e);null!=u&&a.setScale(u);const o=e.geometry?.spatialReference??this._queryEngineParams.spatialReference,l=o.wkid;if(e.geometry&&(F(o)||S(o))){const t=y(_(),g);for(const s of R(e.geometry))w(t,s);a.setOutSpatialReference(l),a.setExtent({xmin:t[0],ymin:t[1],xmax:t[2],ymax:t[3]})}if(e.where){const{id:s,file:r}=t;await this._setWhereClause(a,await r,s,e.where)}return a}async _createParquetDisplayQuery(e,t,s){const r=(await W()).Query.new();return"tile"===s.type?(r.setExtent(s.extent),r.setQuantizationTransform(s.transform),r.setScale(s.scale)):"arcade"===s.type&&null!=s.extent&&r.setExtent(s.extent),r.setOutFields(s.outFields.filter(e=>null!=this._indexMap[e])),r.setOutSpatialReference(s.outSpatialReference.wkid),r.setReturnGeometry(s.returnGeometry),r.setReturnZ(s.returnZ),r.setReturnM(s.returnM),s.where&&await this._setWhereClause(r,e,t,s.where),r}async _getFeatureCount(){return(await this._provider.getFiles()).map(e=>e.statistics.rowCount).reduce((e,t)=>e+t,0)}async _getByteLength(){return(await this._provider.getFiles()).map(e=>e.statistics.byteSize).reduce((e,t)=>e+t,0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new r("parquet:unsupported","Statistics queries are not supported",{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new r("parquet:unsupported","Queries using orderBy are not supported",{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new r("parquet:unsupported","Queries using returnDistinctValues are not supported",{query:e})}async _setWhereClause(e,t,s,i){const a=this._indexMap,n=this._fieldsIndex,u={getAttribute(e,r){const i=a[r];if(null==i){const t=n.get(r);if("__OBJECTID"===t?.name){const t=e.row+e.rowGroupStart;return A(s,t)}return null}const u=t.readAttribute(e.rowGroup,e.row,i);if(null==u)return null;const o=n.get(r);return"esriFieldTypeString"===o.type||"esriFieldTypeDateOnly"===o.type||"esriFieldTypeTimeOnly"===o.type||"esriFieldTypeTimestampOffset"===o.type?K.decode(u):u}},o=await l(i,this._fieldsIndex);if(!o.isStandardized)throw new r("sql-parse-error","expression is not standardized");const c=(e,t,s)=>o.testFeatureCompiled({rowGroup:e,row:t,rowGroupStart:s},u,null),p=o.fieldNames.map(e=>n.get(e)).filter(e=>e&&null!=this._indexMap[e?.name]);e.setWhere(i),e.setWhereEvaluator(c),e.setWhereFields(p.map(e=>e.name))}async*_streamFeatures(e,t,s,r,i){const a=await this._provider.getFiles();let n=0;for(const u of a){const a=n,o=n+u.statistics.rowCount;if(n+=u.statistics.rowCount,null!=t&&t>=o)continue;const l=null!=t?Math.max(t-a,0):null;let c=s;if(null!=s){const e=t??0,r=e+s,i=Math.max(e,a),n=Math.min(r,o);c=Math.max(n-i,0)}if(0===c)continue;const p=await this._createParquetQuery(e,u,l,c,r),d=await u.file,f=await d.executeQuery(p,ee),h=async()=>{const e=await f.next(i);if(!e)return null;const t=new H(this._metadata,this._indexMap,e,u.id);return Se([new Z(t,null,0,!1)],this._queryEngineParams)};let m=await h();for(;null!=m;)yield m,m=await h()}}async _queryFeaturesWithQueryEnginePagination(e,t){const s=[],r=this._streamFeatures(e,null,null,null,t);let i=await r.next();for(;!i.done;){const a=await i.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(const e of a)s.push(e);i=await r.next()}return s}async _queryFeaturesWithUpfrontPagination(e,t){let s,r,i,a=e.resultOffset??0,n=e.resultRecordCount??ee;fe(e)?he(e)||(i=a+n):(a&&(s=a,a=0),r=e.resultRecordCount);const u=[],o=this._streamFeatures(e,s,r,i,t);let l=await o.next();for(;!l.done&&n>0;){const s=await l.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(const e of s)if(a>0)a--;else if(u.push(e),--n<=0)return u;l=await o.next()}return u}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){if(e.objectIds?.length){const s=new Map;for(const t of e.objectIds){const e=j(t),r=Q(t);let i=s.get(e);i||(i=[],s.set(e,i)),i.push(r)}const r=[];for(const[i,a]of s.entries()){const s=await this._executeFileIdQuery(e,i,a,t);for(const e of s)r.push(e)}return new E(r,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:this._hasM,hasZ:this._hasZ,featureAdapter:X,featureIdInfo:this._queryEngineParams.featureIdInfo})}if("1=1"===e.where&&(e.where=null),e.resultOffset??=0,e.resultRecordCount??=await this._getFeatureCount(),e.resultRecordCount>te){if(!(this._displayOptimization&&e.geometry))throw new r("parquet:cannot-execute-query","Unable to execute query, dataset is too large.")}const s=!!e.orderByFields?.length||!!e.outStatistics?.length||!!e.returnDistinctValues,i=s?await this._queryFeaturesWithQueryEnginePagination(e,t):await this._queryFeaturesWithUpfrontPagination(e,t);return s||(e.resultOffset=0),new E(i,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:this._hasM,hasZ:this._hasZ,featureAdapter:X,featureIdInfo:this._queryEngineParams.featureIdInfo})}async _executeFileIdQuery(e,t,s,r){const i=await this._getRequiredFields(e),a=(await W()).Query.new();a.setOutFields(i),a.setReturnGeometry(!!e.returnGeometry),a.setReturnZ(!!e.returnZ),a.setReturnM(!!e.returnM),a.setIds(new Uint32Array(s));const n=await this._getFile(t),u=await n.executeQuery(a,ee,r);let o=await u.next(r),l=0;const c=[];for(;null!=o;){const e=new H(this._metadata,this._indexMap,o,t),s=new Z(e,null,l++,!1);c.push(s),o=await u.next(r)}return Se(c,this._queryEngineParams).executeQueryForOpaqueFeatures(e,r)}async _getRequiredFields(e){const t=new Set;if(e.outStatistics)for(const s of v(this._fieldsIndex,e.outStatistics,e.groupByFieldsForStatistics))t.add(s);else if(e.outFields)for(const s of e.outFields)t.add(s);return(t.has("*")?this._fieldsIndex.fields.map(e=>e.name):Array.from(t)).filter(e=>null!=this._indexMap[e])}_tryGetGeneralizedGeometryScale(e){if(!this._displayOptimization)return null;const t=e.outSR??this._queryEngineParams.spatialReference;if(!F(t)&&!S(t))return null;const s=e.quantizationParameters?.tolerance??e.maxAllowableOffset;return s?x(s,t):null}}function le(e){switch(e){case"fullText":case"having":case"timeExtent":case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"geometry":case"resultOffset":case"resultRecordCount":return!0;default:return!1}}function ce(e){switch(e){case"fullText":case"having":case"timeExtent":case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"geometry":return!0;default:return!1}}function pe(e){switch(e){case"fullText":case"having":case"timeExtent":return!0;case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"resultOffset":case"geometry":case"resultRecordCount":return!1}return!1}function de(e){for(const t in e){const s=t;if(le(s)&&null!==e[s])return!0}return!1}function fe(e){for(const t in e){const s=t;if(ce(s)&&null!==e[s])return!0}return!1}function he(e){for(const t in e){const s=t;if(pe(s)&&null!==e[s])return!0}return!1}function me(e,t){return!!e.outStatistics?.length&&!de(e)&&!e.groupByFieldsForStatistics?.length&&!e.orderByFields?.length&&!e.returnDistinctValues&&!e.returnAggIds&&e.outStatistics.every(e=>ye(e,t))}function ye(e,t){switch(e.statisticType){case"count":return"1"===e.onStatisticField||null!=t.get(e.onStatisticField);case"min":case"max":{const s=t.get(e.onStatisticField);return null!=s&&N(s)}default:return!1}}function ge(e,t){const s="exceedslimit"!==e.statisticType?t.get(e.onStatisticField):null,r="min"!==e.statisticType&&"max"!==e.statisticType||"esriFieldTypeDate"!==s?.type?"esriFieldTypeDouble":s.type;return{name:e.outStatisticFieldName,alias:e.outStatisticFieldName,type:r}}function _e(e,t){switch(e.statisticType){case"count":return we(e,t);case"min":return xe(e,t,Math.min);case"max":return xe(e,t,Math.max);default:return{available:!1,value:null}}}function we(e,t){if("count"!==e.statisticType)return{available:!1,value:null};if("1"===e.onStatisticField)return{available:!0,value:t.reduce((e,t)=>e+t.statistics.rowCount,0)};let s=0;for(const r of t){const t=r.statistics.statistics.get(e.onStatisticField);if(null==t||null==t.nullCount)return{available:!1,value:null};s+=r.statistics.rowCount-t.nullCount}return{available:!0,value:s}}function xe(e,t,s){if("min"!==e.statisticType&&"max"!==e.statisticType)return{available:!1,value:null};let r=null;const i="min"===e.statisticType?"minValue":"maxValue";for(const a of t){const t=a.statistics.statistics.get(e.onStatisticField);if(null==t)return{available:!1,value:null};switch(t.type){case"null-only":continue;case"unknown":return{available:!1,value:null};case"bounds":{const e=Fe(t[i]);if(null==e)return{available:!1,value:null};r=null==r?e:s(r,e);break}}}return{available:!0,value:r}}function Fe(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function Se(e,t){const s=new J;for(const r of e)s.insert(r);return new b({...t,featureStore:s})}function Ie(e,t){return e.statistics.statistics.get(t.fieldName)??null}function ve(e,t){return e.slice().sort((e,s)=>{const r=qe(e,t),i=qe(s,t);return r===i?0:r<i?-1:1})}function qe(e,t){const s=Ie(e,t);return"bounds"!==s?.type?Number.POSITIVE_INFINITY:s.maxValue-s.minValue}function Re(e,t,s){const r=e?.featureCount;let i=!1;return null!=r&&r<has("parquetlayer-full-query-feature-count")&&(i=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:s,supportsTrueCurve:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{...C,maxRecordCount:ee,supportsOrderBy:i,supportsDistinct:!0,supportsStatistics:!0,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1}},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsTrueCurveUpdate:!1,supportsTrueCurveUpdateByTrueCurveClientsOnly:!0,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function be(e){return!!(e.objectIds?.length||e.outStatistics||e.orderByFields?.length||e.returnDistinctValues)}export{oe 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/Accessor.js";import r from"../../../../core/Error.js";import has from"../../../../core/has.js";import{whenOrAbort as o}from"../../../../core/promiseUtils.js";import{urlToObject as s}from"../../../../core/urlUtils.js";import{property as i,subclass as u}from"../../../../core/accessorSupport/decorators.js";import{equals as n}from"../../../../geometry/support/spatialReferenceUtils.js";import{isHostedAgolService as a}from"../../../support/arcgisLayerUrl.js";import{getGltfQueryFormat as c}from"../../../support/infoFor3D.js";import{parseUrl as p}from"../../../../rest/utils.js";import l from"../../../../rest/layerSources/DynamicDataLayer.js";import{executeForCount as d}from"../../../../rest/query/executeForCount.js";import{executeForExtent as m}from"../../../../rest/query/executeForExtent.js";import{executeForIds as y}from"../../../../rest/query/executeForIds.js";import{executeRawQueryJSON as h}from"../../../../rest/query/executeQueryJSON.js";import{executeRawQueryPBF as f}from"../../../../rest/query/executeQueryPBF.js";import F from"../../../../rest/support/FeatureSet.js";import S from"../../../../rest/support/Query.js";let x=class extends t{constructor(e){super(e),this.dynamicDataSource=null,this.fieldsIndex=null,this.gdbVersion=null,this.infoFor3D=null,this.pbfSupported=!1,this.pbfSupportedWithCurves=!1,this.queryAttachmentsSupported=!1,this.relativeTimeBinWindow=0,this.sourceSpatialReference=null,this.uniqueIdFields=null,this.url=null}get parsedUrl(){return s(this.url)}async execute(e,t){const r=await this.executeJSON(e,t);return this.featureSetFromJSON(e,r,t)}async executeJSON(e,t){const r=this._normalizeQuery(e),o=null!=e.outStatistics?.[0],s=has("featurelayer-pbf-statistics");let i;if(this.pbfSupported&&(!o||s)&&(!e.returnTrueCurves||this.pbfSupportedWithCurves))try{i=await f(this.url,r,t,{uniqueIdFields:this.uniqueIdFields})}catch(u){if("query:parsing-pbf"!==u.name)throw u;this.pbfSupported=!1}return i??=await h(this.url,r,t,{uniqueIdFields:this.uniqueIdFields}),this._normalizeFields(i.fields),i}async featureSetFromJSON(e,t,r){if(!this._queryGet3DObjectFormat(e)||null==this.infoFor3D||!t.features)return F.fromJSON(t);const{meshFeatureSetFromJSON:s}=await o(import("../../../../rest/support/meshFeatureSet.js"),r);return s(e,this.infoFor3D,t)}executeForCount(e,t){return d(this.url,this._normalizeQuery(e),t,{uniqueIdFields:this.uniqueIdFields})}executeForExtent(e,t){return m(this.url,this._normalizeQuery(e),t)}executeForIds(e,t){return y(this.url,this._normalizeQuery(e),t,{uniqueIdFields:this.uniqueIdFields})}async executeRelationshipQuery(e,t){const[{default:r},{executeRelationshipQuery:s}]=await o(Promise.all([import("../../../../rest/support/RelationshipQuery.js"),import("../../../../rest/query/executeRelationshipQuery.js")]),t);let i=r.from(e);return(this.gdbVersion||this.dynamicDataSource)&&(i=i.clone(),i.gdbVersion=i.gdbVersion||this.gdbVersion,i.dynamicDataSource=i.dynamicDataSource||this.dynamicDataSource),s(this.url,i,t)}async executeRelationshipQueryForCount(e,t){const[{default:r},{executeRelationshipQueryForCount:s}]=await o(Promise.all([import("../../../../rest/support/RelationshipQuery.js"),import("../../../../rest/query/executeRelationshipQuery.js")]),t);let i=r.from(e);return(this.gdbVersion||this.dynamicDataSource)&&(i=i.clone(),i.gdbVersion=i.gdbVersion||this.gdbVersion,i.dynamicDataSource=i.dynamicDataSource||this.dynamicDataSource),s(this.url,i,t)}async executeAttachmentQuery(e,t){const{executeAttachmentQuery:r,fetchAttachments:s,processAttachmentQueryResult:i}=await o(import("../../../../rest/query/operations/queryAttachments.js"),t),u=p(this.url);return i(u,await(this.queryAttachmentsSupported?r(u,e,t):s(u,e,t)))}async executeAttributeBinsQuery(e,t){const{executeAttributeBinsQuery:r}=await o(import("../../../../rest/query/executeAttributeBinsQuery.js"),t);return r(this.parsedUrl,e,t)}async executePivotQuery(e,t){const{executePivotQuery:r}=await o(import("../../../../rest/query/executePivotQuery.js"),t);return r(this.parsedUrl,e,t)}async executeTopFeaturesQuery(e,t){const{executeTopFeaturesQuery:r}=await o(import("../../../../rest/query/executeTopFeaturesQuery.js"),t);return r(this.parsedUrl,e,this.sourceSpatialReference,t)}async executeForTopIds(e,t){const{executeForTopIds:r}=await o(import("../../../../rest/query/executeForTopIds.js"),t);return r(this.parsedUrl,e,t)}async executeForTopExtents(e,t){const{executeForTopExtents:r}=await o(import("../../../../rest/query/executeForTopExtents.js"),t);return r(this.parsedUrl,e,t)}async executeForTopCount(e,t){const{executeForTopCount:r}=await o(import("../../../../rest/query/executeForTopCount.js"),t);return r(this.parsedUrl,e,t)}_normalizeQuery(e){let t=S.from(e);t.sourceSpatialReference=t.sourceSpatialReference||this.sourceSpatialReference,(this.gdbVersion||this.dynamicDataSource)&&(t=t===e?t.clone():t,t.gdbVersion=e.gdbVersion||this.gdbVersion,t.dynamicDataSource=e.dynamicDataSource?l.from(e.dynamicDataSource):this.dynamicDataSource),t.geometry&&null!=t.num&&null!=t.start&&a(this.url)&&(t=t===e?t.clone():t,t.resultType="tile");const{infoFor3D:o}=this,s=this._queryGet3DObjectFormat(e);if(null!=o&&s){if(t=t===e?t.clone():t,t.formatOf3DObjects=s,t.outSpatialReference&&!n(t.outSpatialReference,this.sourceSpatialReference))throw new r("query:unsupported-out-spatial-reference","3D object feature services do not support projection of geometries");if(null==t.outFields||!t.outFields.includes("*")){t=t===e?t.clone():t,null==t.outFields&&(t.outFields=[]);const{originX:r,originY:s,originZ:i,translationX:u,translationY:n,translationZ:a,scaleX:c,scaleY:p,scaleZ:l,rotationX:d,rotationY:m,rotationZ:y,rotationDeg:h}=o.transformFieldRoles;t.outFields.push(r,s,i,u,n,a,c,p,l,d,m,y,h)}}return t}_normalizeFields(e){if(null!=this.fieldsIndex&&null!=e)for(const t of e){const e=this.fieldsIndex.get(t.name);e&&Object.assign(t,e.toJSON())}}_queryGet3DObjectFormat({returnGeometry:e,multipatchOption:t,outStatistics:r}){return!0!==e||"xyFootprint"===t||r?null:c(this.infoFor3D)}};e([i({type:l})],x.prototype,"dynamicDataSource",void 0),e([i()],x.prototype,"fieldsIndex",void 0),e([i()],x.prototype,"gdbVersion",void 0),e([i()],x.prototype,"infoFor3D",void 0),e([i({readOnly:!0})],x.prototype,"parsedUrl",null),e([i()],x.prototype,"pbfSupported",void 0),e([i()],x.prototype,"pbfSupportedWithCurves",void 0),e([i()],x.prototype,"queryAttachmentsSupported",void 0),e([i()],x.prototype,"relativeTimeBinWindow",void 0),e([i()],x.prototype,"sourceSpatialReference",void 0),e([i()],x.prototype,"uniqueIdFields",void 0),e([i({type:String})],x.prototype,"url",void 0),x=e([u("esri.layers.graphics.sources.support.QueryTask")],x);export{x as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import r from"../../../../core/Error.js";import has from"../../../../core/has.js";import{whenOrAbort as o}from"../../../../core/promiseUtils.js";import{urlToObject as s}from"../../../../core/urlUtils.js";import{property as i,subclass as u}from"../../../../core/accessorSupport/decorators.js";import{equals as n}from"../../../../geometry/support/spatialReferenceUtils.js";import{getGltfQueryFormat as a}from"../../../support/infoFor3D.js";import{parseUrl as c}from"../../../../rest/utils.js";import p from"../../../../rest/layerSources/DynamicDataLayer.js";import{executeForCount as l}from"../../../../rest/query/executeForCount.js";import{executeForExtent as d}from"../../../../rest/query/executeForExtent.js";import{executeForIds as m}from"../../../../rest/query/executeForIds.js";import{executeRawQueryJSON as y}from"../../../../rest/query/executeQueryJSON.js";import{executeRawQueryPBF as h}from"../../../../rest/query/executeQueryPBF.js";import f from"../../../../rest/support/FeatureSet.js";import F from"../../../../rest/support/Query.js";let S=class extends t{constructor(e){super(e),this.dynamicDataSource=null,this.fieldsIndex=null,this.gdbVersion=null,this.infoFor3D=null,this.pbfSupported=!1,this.pbfSupportedWithCurves=!1,this.queryAttachmentsSupported=!1,this.relativeTimeBinWindow=0,this.sourceSpatialReference=null,this.uniqueIdFields=null,this.url=null}get parsedUrl(){return s(this.url)}async execute(e,t){const r=await this.executeJSON(e,t);return this.featureSetFromJSON(e,r,t)}async executeJSON(e,t){const r=this._normalizeQuery(e),o=null!=e.outStatistics?.[0],s=has("featurelayer-pbf-statistics");let i;if(this.pbfSupported&&(!o||s)&&(!e.returnTrueCurves||this.pbfSupportedWithCurves))try{i=await h(this.url,r,t,{uniqueIdFields:this.uniqueIdFields})}catch(u){if("query:parsing-pbf"!==u.name)throw u;this.pbfSupported=!1}return i??=await y(this.url,r,t,{uniqueIdFields:this.uniqueIdFields}),this._normalizeFields(i.fields),i}async featureSetFromJSON(e,t,r){if(!this._queryGet3DObjectFormat(e)||null==this.infoFor3D||!t.features)return f.fromJSON(t);const{meshFeatureSetFromJSON:s}=await o(import("../../../../rest/support/meshFeatureSet.js"),r);return s(e,this.infoFor3D,t)}executeForCount(e,t){return l(this.url,this._normalizeQuery(e),t,{uniqueIdFields:this.uniqueIdFields})}executeForExtent(e,t){return d(this.url,this._normalizeQuery(e),t)}executeForIds(e,t){return m(this.url,this._normalizeQuery(e),t,{uniqueIdFields:this.uniqueIdFields})}async executeRelationshipQuery(e,t){const[{default:r},{executeRelationshipQuery:s}]=await o(Promise.all([import("../../../../rest/support/RelationshipQuery.js"),import("../../../../rest/query/executeRelationshipQuery.js")]),t);let i=r.from(e);return(this.gdbVersion||this.dynamicDataSource)&&(i=i.clone(),i.gdbVersion=i.gdbVersion||this.gdbVersion,i.dynamicDataSource=i.dynamicDataSource||this.dynamicDataSource),s(this.url,i,t)}async executeRelationshipQueryForCount(e,t){const[{default:r},{executeRelationshipQueryForCount:s}]=await o(Promise.all([import("../../../../rest/support/RelationshipQuery.js"),import("../../../../rest/query/executeRelationshipQuery.js")]),t);let i=r.from(e);return(this.gdbVersion||this.dynamicDataSource)&&(i=i.clone(),i.gdbVersion=i.gdbVersion||this.gdbVersion,i.dynamicDataSource=i.dynamicDataSource||this.dynamicDataSource),s(this.url,i,t)}async executeAttachmentQuery(e,t){const{executeAttachmentQuery:r,fetchAttachments:s,processAttachmentQueryResult:i}=await o(import("../../../../rest/query/operations/queryAttachments.js"),t),u=c(this.url);return i(u,await(this.queryAttachmentsSupported?r(u,e,t):s(u,e,t)))}async executeAttributeBinsQuery(e,t){const{executeAttributeBinsQuery:r}=await o(import("../../../../rest/query/executeAttributeBinsQuery.js"),t);return r(this.parsedUrl,e,t)}async executePivotQuery(e,t){const{executePivotQuery:r}=await o(import("../../../../rest/query/executePivotQuery.js"),t);return r(this.parsedUrl,e,t)}async executeTopFeaturesQuery(e,t){const{executeTopFeaturesQuery:r}=await o(import("../../../../rest/query/executeTopFeaturesQuery.js"),t);return r(this.parsedUrl,e,this.sourceSpatialReference,t)}async executeForTopIds(e,t){const{executeForTopIds:r}=await o(import("../../../../rest/query/executeForTopIds.js"),t);return r(this.parsedUrl,e,t)}async executeForTopExtents(e,t){const{executeForTopExtents:r}=await o(import("../../../../rest/query/executeForTopExtents.js"),t);return r(this.parsedUrl,e,t)}async executeForTopCount(e,t){const{executeForTopCount:r}=await o(import("../../../../rest/query/executeForTopCount.js"),t);return r(this.parsedUrl,e,t)}_normalizeQuery(e){let t=F.from(e);t.sourceSpatialReference=t.sourceSpatialReference||this.sourceSpatialReference,(this.gdbVersion||this.dynamicDataSource)&&(t=t===e?t.clone():t,t.gdbVersion=e.gdbVersion||this.gdbVersion,t.dynamicDataSource=e.dynamicDataSource?p.from(e.dynamicDataSource):this.dynamicDataSource);const{infoFor3D:o}=this,s=this._queryGet3DObjectFormat(e);if(null!=o&&s){if(t=t===e?t.clone():t,t.formatOf3DObjects=s,t.outSpatialReference&&!n(t.outSpatialReference,this.sourceSpatialReference))throw new r("query:unsupported-out-spatial-reference","3D object feature services do not support projection of geometries");if(null==t.outFields||!t.outFields.includes("*")){t=t===e?t.clone():t,null==t.outFields&&(t.outFields=[]);const{originX:r,originY:s,originZ:i,translationX:u,translationY:n,translationZ:a,scaleX:c,scaleY:p,scaleZ:l,rotationX:d,rotationY:m,rotationZ:y,rotationDeg:h}=o.transformFieldRoles;t.outFields.push(r,s,i,u,n,a,c,p,l,d,m,y,h)}}return t}_normalizeFields(e){if(null!=this.fieldsIndex&&null!=e)for(const t of e){const e=this.fieldsIndex.get(t.name);e&&Object.assign(t,e.toJSON())}}_queryGet3DObjectFormat({returnGeometry:e,multipatchOption:t,outStatistics:r}){return!0!==e||"xyFootprint"===t||r?null:a(this.infoFor3D)}};e([i({type:p})],S.prototype,"dynamicDataSource",void 0),e([i()],S.prototype,"fieldsIndex",void 0),e([i()],S.prototype,"gdbVersion",void 0),e([i()],S.prototype,"infoFor3D",void 0),e([i({readOnly:!0})],S.prototype,"parsedUrl",null),e([i()],S.prototype,"pbfSupported",void 0),e([i()],S.prototype,"pbfSupportedWithCurves",void 0),e([i()],S.prototype,"queryAttachmentsSupported",void 0),e([i()],S.prototype,"relativeTimeBinWindow",void 0),e([i()],S.prototype,"sourceSpatialReference",void 0),e([i()],S.prototype,"uniqueIdFields",void 0),e([i({type:String})],S.prototype,"url",void 0),S=e([u("esri.layers.graphics.sources.support.QueryTask")],S);export{S 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"../../request.js";import r from"../../core/Error.js";import i from"../../core/Logger.js";import{debounce as o}from"../../core/promiseUtils.js";import{property as s,subclass as a}from"../../core/accessorSupport/decorators.js";import{updateOrigins as n}from"../../core/accessorSupport/originUtils.js";import l from"../../geometry/Extent.js";import p from"../../geometry/HeightModelInfo.js";import c from"../../geometry/SpatialReference.js";import{titleFromUrlAndName as u,parse as d,cleanTitle as y,sanitizeUrlWithLayerId as m}from"../support/arcgisLayerUrl.js";import{id as h}from"../support/commonProperties.js";import{fetchIndexInfo as f}from"../support/I3SIndexInfo.js";import{urlProperty as v,normalizeParsedUrlObject as S}from"../support/multiLayerServiceUtils.js";import{getLoader as g}from"../support/schemaValidatorLoader.js";import w from"../../portal/Portal.js";import x from"../../portal/PortalItem.js";import{createForItemWrite as I}from"../../portal/support/jsonContext.js";import{saveResources as j,updateItemWithResources as b}from"../../webdoc/support/resourceUtils.js";import{evaluateWriteErrors as N}from"../../webdoc/support/saveUtils.js";import{reader as _}from"../../core/accessorSupport/decorators/reader.js";const R=m=>{const R=m;let E=class extends R{constructor(){super(...arguments),this.spatialReference=null,this.fullExtent=null,this.heightModelInfo=null,this.minScale=0,this.maxScale=0,this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.copyright=null,this.sublayerTitleMode="item-title",this.title=null,this.layerId=null,this.url=null,this.indexInfo=null,this._debouncedSaveOperations=o(async(e,t,r)=>{switch(e){case 0:return this._save(t);case 1:return this._saveAs(r,t)}})}readSpatialReference(e,t){return T(t)}readFullExtent(e,t,r){if(null!=e&&"object"==typeof e){const i=null==e.spatialReference?{...e,spatialReference:T(t)}:e;return l.fromJSON(i,r)}const i=t.store,o=T(t);return null==o||null==i?.extent||!Array.isArray(i.extent)||i.extent.some(e=>e<L)?null:new l({xmin:i.extent[0],ymin:i.extent[1],xmax:i.extent[2],ymax:i.extent[3],spatialReference:o})}parseVersionString(e){const t={major:Number.NaN,minor:Number.NaN,versionString:e},r=e.split(".");return r.length>=2&&(t.major=parseInt(r[0],10),t.minor=parseInt(r[1],10)),t}readVersion(e,t){const r=t.store,i=null!=r.version?r.version.toString():"";return this.parseVersionString(i)}readTitlePortalItem(e){return"item-title"!==this.sublayerTitleMode?void 0:e}readTitleService(e,t){if("item-title"===this.sublayerTitleMode)return this.url?u(this.url,t.name):t.name;let r=t.name;if(!r&&this.url){const e=d(this.url);null!=e&&(r=e.title)}const i=this.portalItem?.title;return"item-title-and-service-name"===this.sublayerTitleMode&&i&&(r=i+" - "+r),y(r)}get parsedUrl(){return S(this,{separator:"layers"})}async _fetchIndexAndUpdateExtent(e,t){this.indexInfo=f(this.parsedUrl?.path??"",this.rootNode,e,this.customParameters,this.apiKey,i.getLogger(this),t),this.indexInfo.catch(()=>{});const{fullExtent:r}=this;null==r||r.hasZ||this._updateExtent(r,await this.indexInfo)}_updateExtent(e,t){if("page"===t?.type){const r=t.rootIndex%t.pageSize,i=t.rootPage?.nodes?.[r];A(e,i?.obb)}else if("node"===t?.type){const r=t.rootNode?.mbs;if(!Array.isArray(r)||4!==r.length||r[0]<L)return;const i=r[2],o=r[3];e.zmin=i-o,e.zmax=i+o}}async _fetchService(e){if(null==this.url)throw new r("sceneservice:url-not-set","Scene service can not be loaded without valid portal item or url");if(null==this.layerId&&/SceneServer\/*$/i.test(this.url)){const t=await this._fetchFirstLayerId(e);null!=t&&(this.layerId=t)}return this._fetchServiceLayer(e)}async _fetchFirstLayerId(e){const r=await t(this.url??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});if(r.data&&Array.isArray(r.data.layers)&&r.data.layers.length>0)return r.data.layers[0].id}async _fetchServiceLayer(e){const r=await t(this.parsedUrl?.path??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});r.ssl&&this.url&&(this.url=this.url.replace(/^http:/i,"https:"));let i=!1;if(r.data.layerType&&"Voxel"===r.data.layerType&&(i=!0),i)return this._fetchVoxelServiceLayer();const o=r.data;this.read(o,this._getServiceContext()),this.validateLayer(o)}async _fetchVoxelServiceLayer(e){const r=(await t(this.parsedUrl?.path+"/layer",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e})).data;this.read(r,this._getServiceContext()),this.validateLayer(r)}_getServiceContext(){return{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}}async _ensureLoadBeforeSave(){await this.load(),"beforeSave"in this&&"function"==typeof this.beforeSave&&await this.beforeSave()}validateLayer(e){}async _saveAs(e,t){const i={...P,...t};let o=x.from(e);if(!o)throw new r("sceneservice:portal-item-required","_saveAs() requires a portal item to save to");o.id&&(o=o.clone(),o.id=null);const s=o.portal||w.getDefault();await this._ensureLoadBeforeSave(),o.type=U,o.portal=s;const a=I(o,"portal-item",!0),l={layers:[this.write({},a)]};return await Promise.all(a.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(l,a,i),this.url&&(o.url=this.url),o.title||(o.title=this.title),O(o,i,1),await s.signIn(),await s.user.addItem({item:o,folder:i?.folder,data:l}),await j(this.resourceReferences,a),this.portalItem=o,n(a),a.portalItem=o,o}async _save(e){const t={...P,...e};if(!this.portalItem)throw new r("sceneservice:portal-item-not-set","Portal item to save to has not been set on this SceneService");if(this.portalItem.type!==U)throw new r("sceneservice:portal-item-wrong-type",`Portal item needs to have type "${U}"`);await this._ensureLoadBeforeSave();const i=I(this.portalItem,"portal-item",!0),o=this.write({},i),s=await C(this.portalItem,o);await Promise.all(i.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(s,i,t);const a=q(this.portalItem,this.url);return a&&(this.portalItem.url=a),this.portalItem.title||(this.portalItem.title=this.title),O(this.portalItem,t,0),await b(this.portalItem,s,this.resourceReferences,i),n(i),this.portalItem}async _validateAgainstJSONSchema(e,t,o){const s=o?.validationOptions;N(t,{errorName:"sceneservice:save"},{ignoreUnsupported:s?.ignoreUnsupported,supplementalUnsupportedErrors:["scenemodification:unsupported"]});const a=s?.enabled,n=g();if(a&&n){const t=(await n()).validate(e,o.portalItemLayerType);if(!t.length)return;const a=`Layer item did not validate:\n${t.join("\n")}`;if(i.getLogger(this).error(`_validateAgainstJSONSchema(): ${a}`),"throw"===s.failPolicy){const e=t.map(e=>new r("sceneservice:schema-validation",e));throw new r("sceneservice-validate:error","Failed to save layer item due to schema validation, see `details.errors`.",{validationErrors:e})}}}};return e([s(h)],E.prototype,"id",void 0),e([s({type:c})],E.prototype,"spatialReference",void 0),e([_("spatialReference",["spatialReference","store.indexCRS","store.geographicCRS"])],E.prototype,"readSpatialReference",null),e([s({type:l})],E.prototype,"fullExtent",void 0),e([_("fullExtent",["fullExtent","store.extent","spatialReference","store.indexCRS","store.geographicCRS"])],E.prototype,"readFullExtent",null),e([s({readOnly:!0,type:p})],E.prototype,"heightModelInfo",void 0),e([s({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:{source:"minScale"},write:!1}}}})],E.prototype,"minScale",void 0),e([s({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:{source:"maxScale"},write:!1}}}})],E.prototype,"maxScale",void 0),e([s({readOnly:!0})],E.prototype,"version",void 0),e([_("version",["store.version"])],E.prototype,"readVersion",null),e([s({type:String,json:{read:{source:"copyrightText"}}})],E.prototype,"copyright",void 0),e([s({type:String,json:{read:!1}})],E.prototype,"sublayerTitleMode",void 0),e([s({type:String})],E.prototype,"title",void 0),e([_("portal-item","title")],E.prototype,"readTitlePortalItem",null),e([_("service","title",["name"])],E.prototype,"readTitleService",null),e([s({type:Number,json:{origins:{service:{read:{source:"id"}},"portal-item":{write:{target:"id",isRequired:!0,ignoreOrigin:!0},read:!1}}}})],E.prototype,"layerId",void 0),e([s(v({separator:"layers"}))],E.prototype,"url",void 0),e([s({readOnly:!0})],E.prototype,"parsedUrl",null),e([s({readOnly:!0})],E.prototype,"store",void 0),e([s({type:String,readOnly:!0,json:{read:{source:"store.rootNode"}}})],E.prototype,"rootNode",void 0),E=e([a("esri.layers.mixins.SceneService")],E),E},L=-1e38;function T(e){if(null!=e.spatialReference)return c.fromJSON(e.spatialReference);const t=e.store,r=t.indexCRS||t.geographicCRS,i=r&&parseInt(r.slice(r.lastIndexOf("/")+1),10);return null!=i?new c(i):null}function A(e,t){if(null==t?.center||null==t.halfSize)throw new r("sceneservice:invalid-node-page","Invalid node page.");if(t.center[0]<L)return;const i=t.halfSize,o=t.center[2],s=Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);e.zmin=o-s,e.zmax=o+s}function O(e,t,r){e.typeKeywords||(e.typeKeywords=[]);const i=t.getTypeKeywords();for(const o of i)e.typeKeywords.push(o);e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t),1===r&&(e.typeKeywords=e.typeKeywords.filter(e=>"Hosted Service"!==e)))}const U="Scene Service",P={getTypeKeywords:()=>[],portalItemLayerType:"unknown",validationOptions:{enabled:!0,ignoreUnsupported:!1,failPolicy:"throw"}},E={layerId:null};function K(e,t){const r=e.findIndex(({id:e})=>e===t.id);-1===r?e.push(t):e[r]=t}async function C(e,t){const r=await e.fetchData("json")??{};return Array.isArray(r.layers)||(r.layers=await V(e,t)),K(r.layers,t),r}function q(e,t){return t&&M(e.url,t)?e.url:t}function M(e,t){const r=J(e);return!!r&&r===F(t).url}async function V(e,t){const r=await z(e).catch(()=>null);return r?.some(({id:e})=>e===t.id)?r:[t]}async function z(e){const r=J(e.url);if(!r)return null;const i=(await t(r,{query:{f:"json"},responseType:"json"})).data.layers;if(!Array.isArray(i))return null;const o=i.filter(({id:e})=>null!=e).map(({id:e})=>({id:e}));return o.length?o:null}function J(e){if(!e)return null;const t=F(e);if(null!=t.layerId)return null;const r=d(t.url);return null==r||"SceneServer"===r.serverType?t.url:null}function F(e){return m({layer:E,url:e,nonStandardUrlAllowed:!0})}export{R as SceneService,U as sceneServiceItemType,A as updateExtentFromPageObb};
2
+ import{__decorate as e}from"tslib";import t from"../../request.js";import r from"../../core/Error.js";import i from"../../core/Logger.js";import{debounce as o}from"../../core/promiseUtils.js";import{property as s,subclass as a}from"../../core/accessorSupport/decorators.js";import{updateOrigins as n}from"../../core/accessorSupport/originUtils.js";import l from"../../geometry/Extent.js";import p from"../../geometry/HeightModelInfo.js";import c from"../../geometry/SpatialReference.js";import{titleFromUrlAndName as u,parse as d,cleanTitle as y,sanitizeUrlWithLayerId as m}from"../support/arcgisLayerUrl.js";import{id as h}from"../support/commonProperties.js";import{fetchIndexInfo as f}from"../support/I3SIndexInfo.js";import{urlProperty as v,normalizeParsedUrlObject as S}from"../support/multiLayerServiceUtils.js";import{getLoader as g}from"../support/schemaValidatorLoader.js";import w from"../../portal/Portal.js";import x from"../../portal/PortalItem.js";import{createForItemWrite as I}from"../../portal/support/jsonContext.js";import{saveResources as j,updateItemWithResources as b}from"../../webdoc/support/resourceUtils.js";import{evaluateWriteErrors as N}from"../../webdoc/support/saveUtils.js";import{reader as _}from"../../core/accessorSupport/decorators/reader.js";const R=m=>{const R=m;let E=class extends R{constructor(){super(...arguments),this.spatialReference=null,this.fullExtent=null,this.heightModelInfo=null,this.minScale=0,this.maxScale=0,this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.copyright=null,this.sublayerTitleMode="item-title",this.title=null,this.layerId=null,this.url=null,this.indexInfo=null,this._debouncedSaveOperations=o(async(e,t,r)=>{switch(e){case 0:return this._save(t);case 1:return this._saveAs(r,t)}})}readSpatialReference(e,t){return T(t)}readFullExtent(e,t,r){if(null!=e&&"object"==typeof e){const i=null==e.spatialReference?{...e,spatialReference:T(t)}:e;return l.fromJSON(i,r)}const i=t.store,o=T(t);return null==o||null==i?.extent||!Array.isArray(i.extent)||i.extent.some(e=>e<L)?null:new l({xmin:i.extent[0],ymin:i.extent[1],xmax:i.extent[2],ymax:i.extent[3],spatialReference:o})}parseVersionString(e){const t={major:Number.NaN,minor:Number.NaN,versionString:e},r=e.split(".");return r.length>=2&&(t.major=parseInt(r[0],10),t.minor=parseInt(r[1],10)),t}readVersion(e,t){const r=t.store,i=null!=r.version?r.version.toString():"";return this.parseVersionString(i)}readTitlePortalItem(e){return"item-title"!==this.sublayerTitleMode?void 0:e}readTitleService(e,t){if("item-title"===this.sublayerTitleMode)return this.url?u(this.url,t.name):t.name;let r=t.name;if(!r&&this.url){const e=d(this.url);null!=e&&(r=e.title)}const i=this.portalItem?.title;return"item-title-and-service-name"===this.sublayerTitleMode&&i&&(r=i+" - "+r),y(r)}get parsedUrl(){return S(this,{separator:"layers"})}async _fetchIndexAndUpdateExtent(e,t){this.indexInfo=f(this.parsedUrl?.path??"",this.rootNode,e,this.customParameters,this.apiKey,i.getLogger(this),t),this.indexInfo.catch(()=>{});const{fullExtent:r}=this;null==r||r.hasZ||this._updateExtent(r,await this.indexInfo)}_updateExtent(e,t){if("page"===t?.type){const r=t.rootIndex%t.pageSize,i=t.rootPage?.nodes?.[r];A(e,i?.obb)}else if("node"===t?.type){const r=t.rootNode?.mbs;if(!Array.isArray(r)||4!==r.length||r[0]<L)return;const i=r[2],o=r[3];e.zmin=i-o,e.zmax=i+o}}async _fetchService(e){if(null==this.url)throw new r("sceneservice:url-not-set","Scene service can not be loaded without valid portal item or url");if(null==this.layerId&&/SceneServer\/*$/i.test(this.url)){const t=await this._fetchFirstLayerId(e);null!=t&&(this.layerId=t)}return this._fetchServiceLayer(e)}async _fetchFirstLayerId(e){const r=await t(this.url??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});if(r.data&&Array.isArray(r.data.layers)&&r.data.layers.length>0)return r.data.layers[0].id}async _fetchServiceLayer(e){const r=await t(this.parsedUrl?.path??"",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e});r.ssl&&this.url&&(this.url=this.url.replace(/^http:/i,"https:"));let i=!1;if(r.data.layerType&&"Voxel"===r.data.layerType&&(i=!0),i)return this._fetchVoxelServiceLayer();const o=r.data;this.read(o,this._getServiceContext()),this.validateLayer(o)}async _fetchVoxelServiceLayer(e){const r=(await t(this.parsedUrl?.path+"/layer",{query:{f:"json",...this.customParameters,token:this.apiKey},responseType:"json",signal:e})).data;this.read(r,this._getServiceContext()),this.validateLayer(r)}_getServiceContext(){return{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}}async _ensureLoadBeforeSave(){await this.load(),"beforeSave"in this&&"function"==typeof this.beforeSave&&await this.beforeSave()}validateLayer(e){}async _saveAs(e,t){const i={...P,...t};let o=x.from(e);if(!o)throw new r("sceneservice:portal-item-required","_saveAs() requires a portal item to save to");o.id&&(o=o.clone(),o.id=null);const s=o.portal||w.getDefault();await this._ensureLoadBeforeSave(),o.type=U,o.portal=s;const a=I(o,"portal-item",{withResources:!0}),l={layers:[this.write({},a)]};return await Promise.all(a.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(l,a,i),this.url&&(o.url=this.url),o.title||(o.title=this.title),O(o,i,1),await s.signIn(),await s.user.addItem({item:o,folder:i?.folder,data:l}),await j(this.resourceReferences,a),this.portalItem=o,n(a),a.portalItem=o,o}async _save(e){const t={...P,...e};if(!this.portalItem)throw new r("sceneservice:portal-item-not-set","Portal item to save to has not been set on this SceneService");if(this.portalItem.type!==U)throw new r("sceneservice:portal-item-wrong-type",`Portal item needs to have type "${U}"`);await this._ensureLoadBeforeSave();const i=I(this.portalItem,"portal-item",{withResources:!0}),o=this.write({},i),s=await C(this.portalItem,o);await Promise.all(i.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(s,i,t);const a=q(this.portalItem,this.url);return a&&(this.portalItem.url=a),this.portalItem.title||(this.portalItem.title=this.title),O(this.portalItem,t,0),await b(this.portalItem,s,this.resourceReferences,i),n(i),this.portalItem}async _validateAgainstJSONSchema(e,t,o){const s=o?.validationOptions;N(t,{errorName:"sceneservice:save"},{ignoreUnsupported:s?.ignoreUnsupported,supplementalUnsupportedErrors:["scenemodification:unsupported"]});const a=s?.enabled,n=g();if(a&&n){const t=(await n()).validate(e,o.portalItemLayerType);if(!t.length)return;const a=`Layer item did not validate:\n${t.join("\n")}`;if(i.getLogger(this).error(`_validateAgainstJSONSchema(): ${a}`),"throw"===s.failPolicy){const e=t.map(e=>new r("sceneservice:schema-validation",e));throw new r("sceneservice-validate:error","Failed to save layer item due to schema validation, see `details.errors`.",{validationErrors:e})}}}};return e([s(h)],E.prototype,"id",void 0),e([s({type:c})],E.prototype,"spatialReference",void 0),e([_("spatialReference",["spatialReference","store.indexCRS","store.geographicCRS"])],E.prototype,"readSpatialReference",null),e([s({type:l})],E.prototype,"fullExtent",void 0),e([_("fullExtent",["fullExtent","store.extent","spatialReference","store.indexCRS","store.geographicCRS"])],E.prototype,"readFullExtent",null),e([s({readOnly:!0,type:p})],E.prototype,"heightModelInfo",void 0),e([s({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:{source:"minScale"},write:!1}}}})],E.prototype,"minScale",void 0),e([s({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:{source:"maxScale"},write:!1}}}})],E.prototype,"maxScale",void 0),e([s({readOnly:!0})],E.prototype,"version",void 0),e([_("version",["store.version"])],E.prototype,"readVersion",null),e([s({type:String,json:{read:{source:"copyrightText"}}})],E.prototype,"copyright",void 0),e([s({type:String,json:{read:!1}})],E.prototype,"sublayerTitleMode",void 0),e([s({type:String})],E.prototype,"title",void 0),e([_("portal-item","title")],E.prototype,"readTitlePortalItem",null),e([_("service","title",["name"])],E.prototype,"readTitleService",null),e([s({type:Number,json:{origins:{service:{read:{source:"id"}},"portal-item":{write:{target:"id",isRequired:!0,ignoreOrigin:!0},read:!1}}}})],E.prototype,"layerId",void 0),e([s(v({separator:"layers"}))],E.prototype,"url",void 0),e([s({readOnly:!0})],E.prototype,"parsedUrl",null),e([s({readOnly:!0})],E.prototype,"store",void 0),e([s({type:String,readOnly:!0,json:{read:{source:"store.rootNode"}}})],E.prototype,"rootNode",void 0),E=e([a("esri.layers.mixins.SceneService")],E),E},L=-1e38;function T(e){if(null!=e.spatialReference)return c.fromJSON(e.spatialReference);const t=e.store,r=t.indexCRS||t.geographicCRS,i=r&&parseInt(r.slice(r.lastIndexOf("/")+1),10);return null!=i?new c(i):null}function A(e,t){if(null==t?.center||null==t.halfSize)throw new r("sceneservice:invalid-node-page","Invalid node page.");if(t.center[0]<L)return;const i=t.halfSize,o=t.center[2],s=Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);e.zmin=o-s,e.zmax=o+s}function O(e,t,r){e.typeKeywords||(e.typeKeywords=[]);const i=t.getTypeKeywords();for(const o of i)e.typeKeywords.push(o);e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t),1===r&&(e.typeKeywords=e.typeKeywords.filter(e=>"Hosted Service"!==e)))}const U="Scene Service",P={getTypeKeywords:()=>[],portalItemLayerType:"unknown",validationOptions:{enabled:!0,ignoreUnsupported:!1,failPolicy:"throw"}},E={layerId:null};function K(e,t){const r=e.findIndex(({id:e})=>e===t.id);-1===r?e.push(t):e[r]=t}async function C(e,t){const r=await e.fetchData("json")??{};return Array.isArray(r.layers)||(r.layers=await V(e,t)),K(r.layers,t),r}function q(e,t){return t&&M(e.url,t)?e.url:t}function M(e,t){const r=J(e);return!!r&&r===F(t).url}async function V(e,t){const r=await z(e).catch(()=>null);return r?.some(({id:e})=>e===t.id)?r:[t]}async function z(e){const r=J(e.url);if(!r)return null;const i=(await t(r,{query:{f:"json"},responseType:"json"})).data.layers;if(!Array.isArray(i))return null;const o=i.filter(({id:e})=>null!=e).map(({id:e})=>({id:e}));return o.length?o:null}function J(e){if(!e)return null;const t=F(e);if(null!=t.layerId)return null;const r=d(t.url);return null==r||"SceneServer"===r.serverType?t.url:null}function F(e){return m({layer:E,url:e,nonStandardUrlAllowed:!0})}export{R as SceneService,U as sceneServiceItemType,A as updateExtentFromPageObb};
@@ -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 i from"../../../core/Error.js";import{JSONSupport as o}from"../../../core/JSONSupport.js";import r from"../../../core/Logger.js";import{debounce as n,onAbort as s}from"../../../core/promiseUtils.js";import{QueueProcessor as l}from"../../../core/QueueProcessor.js";import{property as a,subclass as c}from"../../../core/accessorSupport/decorators.js";import{ensureClass as f}from"../../../core/accessorSupport/ensureType.js";import u from"../../../geometry/Extent.js";import m from"../../../geometry/Point.js";import h from"../../../geometry/SpatialReference.js";import{isFunctionRaster as p,getPixelSpaceCoverage as d}from"./datasetUtils.js";import{isMultiSliceOrRangeDefinition as x,getSliceIndex as y,createSlices as g,getSliceIds as I}from"./multidimensionalUtils.js";import{clearRegisteredIds as R,getRasterId as w,getBlock as S,putBlock as k,deleteBlock as b,decreaseRefCount as T}from"./RawBlockCache.js";import{convertNoDataToMask as v}from"../formats/pixelRangeUtils.js";import{decode as P}from"../formats/RasterCodec.js";import{mosaic as B,approximateTransform as _,getLocalArithmeticNorthRotations as M,compositeBands as W}from"../functions/pixelUtils.js";import{getWorldWidth as C,load as H,projectPoint as z,snapPyramid as L,shiftExtent as j,getWorldWrapCount as E,projectExtent as D,getProjectionOffsetGrid as O,getRasterDatasetAlignmentInfo as A,projectResolution as q}from"../functions/rasterProjectionHelper.js";import{convertToLocalDirections as F,uvComponentToVector as G}from"../functions/vectorFieldUtils.js";import{sanitizeUrl as J}from"../../support/arcgisLayerUrl.js";import{url as N}from"../../support/commonProperties.js";import V from"../../support/DimensionalDefinition.js";import U from"../../support/LOD.js";import Q from"../../support/RasterStorageInfo.js";import $ from"../../support/TileInfo.js";const X=8,K=256;let Y=0,Z=class extends o{constructor(){super(...arguments),this._tileFetchQueue=new l({concurrency:32,process:(e,t)=>this.fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:"closest"},this.rawBlockRegistryIds=[],this.refresh=n(async e=>{await this._openPromise;const t=await this._refresh(e);return t.dataChanged&&R(this.rasterId,this.rawBlockRegistryIds),t})}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:$.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=C(e.spatialReference);return null!=t&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){const{transform:e}=this.rasterInfo;return null==e||"gcs-shift"===e.type}set rasterJobHandler(e){this._set("rasterJobHandler",e),p(this)&&this.primaryRasters?.rasters?.forEach(t=>t.rasterJobHandler=e)}get rasterId(){return this.url||"rasterId-"+Y++}set url(e){this._set("url",J(e,r.getLogger(this)))}async open(e){return this._openPromise??=H().then(()=>this._open(e)),this._openPromise}async fetchTile(e,t,o,r={}){const n=r.tileInfo||this.rasterInfo.storageInfo.tileInfo,s=this.getTileExtentFromTileInfo(e,t,o,n);if(!s)throw new i("imagery-tile:out-of-bounds","Level for fetch tile out of range");return r={noClip:!0,...r},this.fetchPixels(s,n.size[0],n.size[1],r)}async identify(e,t={}){e=f(m,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:o}=t,{rasterInfo:r}=this,{hasMultidimensionalTranspose:n,multidimensionalInfo:s}=r;let{transposedVariableName:l}=t;const a=null!=s&&n&&(null!=o||x(i));if(a&&!l){l=null!=i&&i.length>0?i[0].variableName??void 0:s.variables[0].name,t={...t,transposedVariableName:l}}t=this._getRequestOptionsWithSliceId(t);const{spatialReference:c,extent:h}=r,{datumTransformation:d}=t;let y=z(e,c,d);if(!h.intersects(y))return{location:y,value:null};if(null!=r.transform){const e=r.transform.inverseTransform(y);if(!r.nativeExtent.intersects(e))return{location:e,value:null};y=e}let g=0;const I=null!=l&&null!=s&&r.hasMultidimensionalTranspose;if(p(this)){const e=this.primaryRasters.rasters[0];if(I)return e.identify(y,t);const{pixelSize:o}=r,n=3,s=o.x*n/2,l=o.y*n/2,a=new u({xmin:y.x-s,xmax:y.x+s,ymin:y.y-l,ymax:y.y+l,spatialReference:c}),f={interpolation:"nearest",multidimensionalDefinition:i,sliceId:t.sliceId,bandIds:t.bandIds},{pixelBlock:m}=await e.fetchPixels(a,n,n,f),{pixelBlock:h}=await this.fetchPixels(a,n,n,f);if(null==m)return{location:y,value:null};const p=Math.floor(n*n*.5),d=!m.mask||m.mask[p]?m.pixels.map(e=>e[p]):null;let x;return null!=h&&(x=!h.mask||h.mask[p]?h.pixels.map(e=>e[p]):void 0),{location:y,value:d,processedValue:x,pyramidLevel:0}}if(!I)if(t.srcResolution){g=L(t.srcResolution,r,this.ioConfig.sampling).pyramidLevel}else if(g=await this.computeBestPyramidLevelForLocation(e,t),null==g)return{location:y,value:null};const R=this.identifyPixelLocation(y,g,null,I);if(null===R)return{location:y,value:null};const{row:w,col:S,rowOffset:k,colOffset:b,blockWidth:T}=R,v=await this._fetchRawTile(g,w,S,t);if(!v?.pixels?.length)return{location:y,value:null};const P=k*T+b;return this._processIdentifyResult(v,{srcLocation:y,position:P,pyramidLevel:g,useTransposedTile:!!I,requestSomeSlices:a,identifyOptions:t})}async fetchPixels(e,t,i,o={}){e=j(e),o=this._getRequestOptionsWithSliceId(o);const{_hasNoneOrGCSShiftTransform:r}=this;if(o.requestRawData&&r)return this._fetchPixels(e,t,i,o);const n=C(e.spatialReference),s=E(e);if(null==n||0===s||1===s&&this._isGlobalWrappableSource&&r)return this._fetchPixels(e,t,i,o);if(s>=3)return{extent:e,pixelBlock:null};const l=[],{xmin:a,xmax:c}=e,f=Math.round(n/(c-a)*t),m=f-Math.round((n/2-a)/(c-a)*t);let h=0;const p=[];for(let g=0;g<=s;g++){const r=new u({xmin:0===g?a:-n/2,xmax:g===s?c-n*g:n/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),d=0===g?f-m:g===s?t-h:f;h+=d,p.push(d);const x=o.disableWrapAround&&g>0?null:this._fetchPixels(r,d,i,o);l.push(x)}const d=(await Promise.all(l)).map(e=>e?.pixelBlock);let x=null;const y={width:t,height:i};if(this.rasterJobHandler){x=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:d,srcMosaicSize:y,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:p},o)).pixelBlock}else x=B(d,y,{blockWidths:p});return{extent:e,srcExtent:D(e,this.rasterInfo.spatialReference,o.datumTransformation),pixelBlock:x}}async fetchRawPixels(e,t,i,o={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const r=await this._fetchRawTiles(e,t,i,o),{nativeExtent:n,nativePixelSize:s,storageInfo:l}=this.rasterInfo,a=2**e,c=s.x*a,f=s.y*a,m=new u({xmin:n.xmin+c*t.x,xmax:n.xmin+c*(t.x+i.width-1),ymin:n.ymax-f*(t.y+i.height-1),ymax:n.ymax-f*t.y,spatialReference:n.spatialReference});if(!r)return{extent:m,srcExtent:m,pixelBlock:null};const{pixelBlocks:h,mosaicSize:p}=r;if(1===h.length&&null!=h[0]&&h[0].width===i.width&&h[0].height===i.height)return{extent:m,srcExtent:m,pixelBlock:r.pixelBlocks[0]};const d=e>0?l.pyramidBlockWidth:l.blockWidth,x=e>0?l.pyramidBlockHeight:l.blockHeight,y={x:t.x%d,y:t.y%x};let g;if(this.rasterJobHandler){g=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:h,srcMosaicSize:p,destDimension:i,clipOffset:y,clipSize:i,coefs:null,sampleSpacing:null,interpolation:o.interpolation,alignmentInfo:null,blockWidths:null},o)).pixelBlock}else g=B(h,p,{clipOffset:y,clipSize:i});return{extent:m,srcExtent:m,pixelBlock:g}}fetchRawTile(e,t,o,r){throw new i("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return D(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return this.rasterJobHandler?this.rasterJobHandler.decode({data:e,options:t}):P(e,t)}async request(e,i,o=0){const{customFetchParameters:r}=this.ioConfig,{range:n,query:s,headers:l}=i;o=o??i.retryCount??this.ioConfig.retryCount;const a=n?{Range:`bytes=${n.from}-${n.to}`}:null;try{return await t(e,{...i,query:{...s,...r},headers:{...l,...a}})}catch(c){if(o>0)return o--,this.request(e,i,o);throw c}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:y(e,t)}getTileExtentFromTileInfo(e,t,i,o){const r=o.lodAt(e);return r?this.getTileExtent({x:r.resolution,y:r.resolution},t,i,o.origin,o.spatialReference,o.size):null}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:o}=this.rasterInfo,{pyramidResolutions:r}=e;if(!e.tileInfo){const n=[],s=e.maximumPyramidLevel||0;let l=(o.x+o.y)/2,a=1/.0254*96*l;for(let e=0;e<=s&&(n.unshift(new U({level:s-e,resolution:l,scale:a})),e!==s);e++)if(r){const t=(r[e].x+r[e].y)/2;a*=t/l,l=t}else l*=2,a*=2;const c=new m({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new $({origin:c,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:n}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,o){const{width:r,height:n,nativeExtent:s,pixelSize:l,spatialReference:a}=e,c=new m({x:s.xmin,y:s.ymax,spatialReference:a});null==o&&(o=Math.max(0,Math.round(Math.log(Math.max(r,n))/Math.LN2-8)));const f=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[l],o);e.storageInfo=new Q({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:o,blockBoundary:f})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,o,r,n=0,s=2){if(1===r.length&&n>0){r=[...r];let{x:e,y:t}=r[0];for(let i=0;i<n;i++)e*=s,t*=s,r.push({x:e,y:t})}const l=[],{x:a,y:c}=o;for(let f=0;f<r.length;f++){const{x:o,y:n}=r[f];l.push({minCol:Math.floor((e.xmin-a+.1*o)/t/o),maxCol:Math.floor((e.xmax-a-.1*o)/t/o),minRow:Math.floor((c-e.ymax+.1*n)/i/n),maxRow:Math.floor((c-e.ymin-.1*n)/i/n)})}return l}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:i,pyramidScalingFactor:o}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=i&&i.length)return i[e-1];const r=o**e;return{x:t.x*r,y:t.y*r}}identifyPixelLocation(e,t,i,o){const{spatialReference:r,nativeExtent:n,storageInfo:s}=this.rasterInfo,{maximumPyramidLevel:l,origin:a,transposeInfo:c}=s,f=o&&null!=c?c.tileSize[0]:s.blockWidth,u=o&&null!=c?c.tileSize[1]:s.blockHeight,m=z(e,r,i);if(!n.intersects(m))return null;if(t<0||t>l)return null;const h=this.getPyramidPixelSize(t),{x:p,y:d}=h,x=(a.y-m.y)/d/u,y=(m.x-a.x)/p/f,g=Math.min(u-1,Math.floor((x-Math.floor(x))*u)),I=Math.min(f-1,Math.floor((y-Math.floor(y))*f));return{pyramidLevel:t,row:Math.floor(x),col:Math.floor(y),rowOffset:g,colOffset:I,blockWidth:f,srcLocation:m}}getTileExtent(e,t,i,o,r,n){const[s,l]=n,a=o.x+i*s*e.x,c=a+s*e.x,f=o.y-t*l*e.y,m=f-l*e.y;return new u({xmin:a,xmax:c,ymin:m,ymax:f,spatialReference:r})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,i){const o=this.rasterInfo.storageInfo.blockBoundary[e];return!o||o.maxRow<t||o.maxCol<i||o.minRow>t||o.minCol>i}updateImageSpaceRasterInfo(e){const{pixelSize:t}=e,{width:i,height:o}=e,r=h.WebMercator;e.spatialReference=r,e.extent=e.nativeExtent=new u({xmin:-.5,ymax:.5,xmax:i-.5,ymin:.5-o,spatialReference:r}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new m({x:1,y:1,spatialReference:r});const{extent:n,storageInfo:s}=e;if(s){s.origin=new m({x:n.xmin,y:n.ymax,spatialReference:r});const{pyramidResolutions:i,tileInfo:o}=s;if(i&&i.forEach(e=>{e.x/=t.x,e.y/=t.y}),o){o.origin=s.origin;const t=(e.nativePixelSize.x+e.nativePixelSize.y)/2;o.lods.forEach((e,i)=>{e.resolution=t*2**i,e.scale=96*e.resolution/.0254})}}}async _refresh(e){return{dataChanged:!0}}async _fetchPixels(e,t,i,o={}){let r=E(e);if(r>=2)return{extent:e,pixelBlock:null};const n=this._getSourceDataInfo(e,t,i,o),{pyramidLevel:s,srcResolution:l,srcWidth:a,srcHeight:c,ul:f}=n;let{srcExtent:u}=n;if(0===a||0===c)return{extent:e,srcExtent:u,pixelBlock:null};const{rasterInfo:h}=this,p=h.transform,d="gcs-shift"===p?.type,x=null!=C(e.spatialReference);!d&&x||(r=E(u,d));const y=await this._fetchRawTiles(s,f,{width:a,height:c,wrapCount:r},o);if(!y)return{extent:e,srcExtent:u,pixelBlock:null};u=y.extent;const g=h.storageInfo,I=s>0?g.pyramidBlockWidth:g.blockWidth,R=s>0?g.pyramidBlockHeight:g.blockHeight;let{x:w,y:S}=h.pixelSize;if(s>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=g;if(null!=e&&e[s-1])({x:w,y:S}=e[s-1]);else{const e=t**s;w*=e,S*=e}}const k=h.spatialReference,b=new m({x:w,y:S,spatialReference:k}),T=I===a&&R===c&&f.x%I===0&&f.y%R===0,v=new m({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),P=!e.spatialReference.equals(k),W=k.isGeographic?1e-9:1e-4,{datumTransformation:z}=o;if(!P&&T&&1===y.pixelBlocks.length&&I===t&&R===i&&ee(l,v,W))return{extent:e,srcExtent:u,srcTilePixelSize:b,pixelBlock:y.pixelBlocks[0]};const L=x&&null!=C(u.spatialReference)&&this._hasNoneOrGCSShiftTransform,j=o.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");j&&!this.rasterJobHandler&&await H();const D=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:u,pixelSize:v.toJSON(),datumTransformation:z,rasterTransform:p,hasWrapAround:r>0||L,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:j},o):O({projectedExtent:e,srcBufferExtent:u,pixelSize:v,datumTransformation:z,rasterTransform:p,hasWrapAround:r>0||L,isAdaptive:!1,includeGCSGrid:j});let A;const q=!o.requestRawData,G={rows:D.spacing[0],cols:D.spacing[1]},J=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(s,u.xmin):void 0,{pixelBlocks:N,mosaicSize:V,isPartiallyFilled:U}=y;let Q=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:N,srcMosaicSize:V,destDimension:q?{width:t,height:i}:null,coefs:q?D.coefficients:null,sampleSpacing:q?G:null,projectDirections:j,gcsGrid:j?D.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:o.interpolation,alignmentInfo:J,blockWidths:null},o);({pixelBlock:A,localNorthDirections:Q}=e)}else{const e=B(N,V,{alignmentInfo:J});A=q?_(e,{width:t,height:i},D.coefficients,G,o.interpolation):e,j&&D.gcsGrid&&(Q=M({width:t,height:i},D.gcsGrid),A=F(A,this.rasterInfo.dataType,Q))}return o.requestRawData||j?{extent:e,srcExtent:u,srcTilePixelSize:b,pixelBlock:A,transformGrid:D,localNorthDirections:Q,isPartiallyFilled:U}:{extent:e,srcExtent:e,srcTilePixelSize:b,pixelBlock:A}}async _fetchRawTiles(e,t,i,o){const{origin:r,blockBoundary:n}=this.rasterInfo.storageInfo,{blockWidth:s,blockHeight:l}=this.getBlockWidthHeight(e);let{x:a,y:c}=t,{width:f,height:m,wrapCount:h}=i;const p=this._getRasterTileAlignmentInfo(e,0);o.buffer&&(a-=o.buffer.cols,c-=o.buffer.rows,f+=2*o.buffer.cols,m+=2*o.buffer.rows);let d=0,x=0,y=0;if(h&&null!=p){({worldColumnCountFromOrigin:x,originColumnOffset:y,rightPadding:d}=p);x*p.blockWidth-d>=a+f&&(d=0)}const g=Math.floor(a/s),I=Math.floor(c/l),R=Math.floor((a+f+d-1)/s),w=Math.floor((c+m+d-1)/l),S=n[e];if(!S)return null;const{minRow:k,minCol:b,maxCol:T,maxRow:v}=S;if(0===h&&(w<k||R<b||I>v||g>T))return null;const P=new Array;let B=!1;const _=null==this.ioConfig.allowPartialFill?o.allowPartialFill:this.ioConfig.allowPartialFill;for(let u=I;u<=w;u++)for(let t=g;t<=R;t++){let i=t;if(!o.disableWrapAround&&h&&null!=p&&x<=t&&(i=t-x-y),u>=k&&i>=b&&v>=u&&T>=i){const t=this._fetchRawTile(e,u,i,o);_?P.push(new Promise(e=>{t.then(t=>e(t)).catch(()=>{B=!0,e(null)})})):P.push(t)}else P.push(Promise.resolve(null))}if(0===P.length)return null;const M=await Promise.all(P),W={height:(w-I+1)*l,width:(R-g+1)*s},{spatialReference:C}=this.rasterInfo,H=this.getPyramidPixelSize(e),{x:z,y:L}=H;return{extent:new u({xmin:r.x+g*s*z,xmax:r.x+(R+1)*s*z,ymin:r.y-(w+1)*l*L,ymax:r.y-I*l*L,spatialReference:C}),pixelBlocks:M,mosaicSize:W,isPartiallyFilled:B}}_fetchRawTile(e,t,i,o){const{storageInfo:r}=this.rasterInfo,n=null!=r.transposeInfo&&!!o.transposedVariableName;if(!n){const o=r.blockBoundary[e];if(!o)return Promise.resolve(null);const{minRow:n,minCol:s,maxCol:l,maxRow:a}=o;if(t<n||i<s||t>a||i>l)return Promise.resolve(null)}const l=n?o.transposeVariableName:o.sliceId,a=r.isBsqTile?o.bandIds:null,c=w(this.rasterId,l,a),f=`${e}/${t}/${i}`;let u=S(c,o.registryId,f);if(null==u){const n=new AbortController,s=o.bandIds?.slice();if(s?.length&&r.isBsqTile){const r=new Set(s),l=[],a=Array.from(r);for(const s of a)l.push(this._tileFetchQueue.push({pyramidLevel:e,row:t,col:i,options:{...o,bandIds:[s]}},{signal:n.signal}));u=Promise.all(l).then(e=>{if(e.some(e=>null==e))return null;if(a.length!==s.length){const t=[];for(const i of s){let o=e[a.indexOf(i)];t.includes(o)&&(o=o.clone()),t.push(o)}e=t}return this.rasterJobHandler?this.rasterJobHandler.compositeBands({pixelBlocks:e},{signal:n.signal,transferPixelsToWorker:!0}):W(e)})}else u=this._tileFetchQueue.push({pyramidLevel:e,row:t,col:i,options:o},{signal:n.signal});k(c,o.registryId,f,u,n),u.catch(()=>b(c,o.registryId,f))}return o.signal&&s(o,()=>{T(c,o.registryId,f)}),u}_computeMagDirValues(e){const{bandCount:t,dataType:i}=this.rasterInfo;if(!(2===t&&"vector-magdir"===i||"vector-uv"===i)||2!==e?.length||!e[0]?.length)return null;const o=e[0].length;if("vector-magdir"===i){const t=e[1].map(e=>(e+360)%360);return[e[0],t]}const[r,n]=e,s=[],l=[];for(let a=0;a<o;a++){const[e,t]=G([r[a],n[a]]);s.push(e),l.push(t)}return[s,l]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlignmentInfo&&(this._rasterTileAlignmentInfo=A(this.rasterInfo)),null==this._rasterTileAlignmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,i,o={}){const r={datumTransformation:o.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};o.srcResolution&&(r.srcResolution=o.srcResolution,this._updateSourceDataInfo(e,r));const n=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:s,srcHeight:l,pyramidLevel:a}=r,c=s/t,f=l/i,u=a<n&&c*f>=16,h=a===n&&this._requireTooManySrcTiles(s,l,t,i);if(u||h||(0===s||0===l)){const s=new m({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference});let l=q(s,this.rasterInfo.spatialReference,e,r.datumTransformation);const h=!l||o.srcResolution&&l.x+l.y<o.srcResolution.x+o.srcResolution.y;if(u&&o.srcResolution&&h){const e=Math.round(Math.log(Math.max(c,f))/Math.LN2)-1;if(n-a+3>=e){const t=2**e;l={x:o.srcResolution.x*t,y:o.srcResolution.y*t}}}l&&(r.srcResolution=l,this._updateSourceDataInfo(e,r))}return this._requireTooManySrcTiles(r.srcWidth,r.srcHeight,t,i)&&(r.srcWidth=0,r.srcHeight=0),r}_requireTooManySrcTiles(e,t,i,o){const{tileInfo:r}=this.rasterInfo.storageInfo,n=Math.ceil(e/r.size[0])*Math.ceil(t/r.size[1]),s=e/i,l=t/o,a=Math.max(1,(i+o)/1024);return n>=K*a||s>X||l>X}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,o=i.spatialReference,{srcResolution:r,datumTransformation:n}=t,{pyramidLevel:s,pyramidResolution:l,excessiveReading:a}=L(r,i,this.ioConfig.sampling);if(a)return;let c=t.srcExtent||D(e,o,n);if(null==c)return;const f=i.transform;f&&(c=f.inverseTransform(c)),t.srcExtent=c;const{origin:u}=i.storageInfo,{width:m,height:h,ul:p}=d(c,u,l,s);t.pyramidLevel=s,t.pyramidResolution=l,t.srcWidth=m,t.srcHeight=h,t.ul=p}_getRequestOptionsWithSliceId(e){return null!=this.rasterInfo.multidimensionalInfo&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:i,position:o,pyramidLevel:r,useTransposedTile:n}=t,s=e.pixels[0].length/e.width/e.height;if(!(!e.mask||e.mask[o]))return{location:i,value:null};const{multidimensionalInfo:l}=this.rasterInfo;if(null==l||!n){const t=e.pixels.map(e=>e[o]),n={location:i,value:t,pyramidLevel:r},s=this._computeMagDirValues(t.map(e=>[e]));return s?.length&&(n.magdirValue=s.map(e=>e[0])),n}let a=e.pixels.map(e=>e.slice(o*s,o*s+s)),c=this._computeMagDirValues(a);const{requestSomeSlices:f,identifyOptions:u}=t;let m=g(l,u.transposedVariableName);if(f){const e=I(m,u.multidimensionalDefinition,u.timeExtent);a=a.map(t=>e.map(e=>t[e])),c=c?.map(t=>e.map(e=>t[e])),m=e.map(e=>m[e])}const h=e.noDataValues||this.rasterInfo.noDataValue,p={pixels:a,pixelType:e.pixelType};let d;null!=h&&(v(p,h),d=p.mask);return{location:i,value:null,dataSeries:m.map((e,t)=>{const i={value:0===d?.[t]?null:a.map(e=>e[t]),multidimensionalDefinition:e.multidimensionalDefinition.map(e=>new V({...e,isSlice:!0}))};return c?.length&&(i.magdirValue=[c[0][t],c[1][t]]),i}),pyramidLevel:r}}};function ee(e,t,i){return Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i}e([a()],Z.prototype,"_rasterTileAlignmentInfo",void 0),e([a()],Z.prototype,"_tileFetchQueue",void 0),e([a({readOnly:!0})],Z.prototype,"_isGlobalWrappableSource",null),e([a({readOnly:!0})],Z.prototype,"_hasNoneOrGCSShiftTransform",null),e([a()],Z.prototype,"_openPromise",void 0),e([a()],Z.prototype,"rasterJobHandler",null),e([a({readOnly:!0})],Z.prototype,"rasterId",null),e([a(N)],Z.prototype,"url",null),e([a({type:String,json:{write:!0}})],Z.prototype,"datasetName",void 0),e([a({type:String,json:{write:!0}})],Z.prototype,"datasetFormat",void 0),e([a()],Z.prototype,"hasUniqueSourceStorageInfo",void 0),e([a()],Z.prototype,"rasterInfo",void 0),e([a()],Z.prototype,"ioConfig",void 0),e([a()],Z.prototype,"sourceJSON",void 0),e([a()],Z.prototype,"rawBlockRegistryIds",void 0),Z=e([c("esri.layers.raster.datasets.BaseRaster")],Z);export{Z as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../request.js";import i from"../../../core/Error.js";import{JSONSupport as r}from"../../../core/JSONSupport.js";import o from"../../../core/Logger.js";import{debounce as n,onAbort as s}from"../../../core/promiseUtils.js";import{QueueProcessor as l}from"../../../core/QueueProcessor.js";import{property as a,subclass as c}from"../../../core/accessorSupport/decorators.js";import{ensureClass as f}from"../../../core/accessorSupport/ensureType.js";import u from"../../../geometry/Extent.js";import m from"../../../geometry/Point.js";import h from"../../../geometry/SpatialReference.js";import{isFunctionRaster as p,getPixelSpaceCoverage as d}from"./datasetUtils.js";import{isMultiSliceOrRangeDefinition as x,getSliceIndex as y,createSlices as g,getSliceIds as I}from"./multidimensionalUtils.js";import{clearRegisteredIds as w,getRasterId as R,getBlock as S,putBlock as k,deleteBlock as b,decreaseRefCount as T}from"./RawBlockCache.js";import{convertNoDataToMask as v}from"../formats/pixelRangeUtils.js";import{decode as P}from"../formats/RasterCodec.js";import{convertPixelSize as B}from"../functions/clipUtils.js";import{mosaic as _,approximateTransform as M,getLocalArithmeticNorthRotations as W,compositeBands as C}from"../functions/pixelUtils.js";import{getWorldWidth as H,load as z,projectPoint as L,snapPyramid as j,shiftExtent as E,getWorldWrapCount as D,projectExtent as O,getProjectionOffsetGrid as A,getRasterDatasetAlignmentInfo as q,projectResolution as F}from"../functions/rasterProjectionHelper.js";import{convertToLocalDirections as G,uvComponentToVector as J}from"../functions/vectorFieldUtils.js";import{sanitizeUrl as N}from"../../support/arcgisLayerUrl.js";import{url as V}from"../../support/commonProperties.js";import U from"../../support/DimensionalDefinition.js";import Q from"../../support/LOD.js";import $ from"../../support/RasterStorageInfo.js";import X from"../../support/TileInfo.js";const K=8,Y=256;let Z=0,ee=class extends r{constructor(){super(...arguments),this._tileFetchQueue=new l({concurrency:32,process:(e,t)=>this.fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:"closest"},this.rawBlockRegistryIds=[],this.refresh=n(async e=>{await this._openPromise;const t=await this._refresh(e);return t.dataChanged&&w(this.rasterId,this.rawBlockRegistryIds),t})}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:X.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=H(e.spatialReference);return null!=t&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){const{transform:e}=this.rasterInfo;return null==e||"gcs-shift"===e.type}set rasterJobHandler(e){this._set("rasterJobHandler",e),p(this)&&this.primaryRasters?.rasters?.forEach(t=>t.rasterJobHandler=e)}get rasterId(){return this.url||"rasterId-"+Z++}set url(e){this._set("url",N(e,o.getLogger(this)))}async open(e){return this._openPromise??=z().then(()=>this._open(e)),this._openPromise}async fetchTile(e,t,r,o={}){const n=o.tileInfo||this.rasterInfo.storageInfo.tileInfo,s=this.getTileExtentFromTileInfo(e,t,r,n);if(!s)throw new i("imagery-tile:out-of-bounds","Level for fetch tile out of range");return o={noClip:!0,...o},this.fetchPixels(s,n.size[0],n.size[1],o)}async identify(e,t={}){e=f(m,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:r}=t,{rasterInfo:o}=this,{hasMultidimensionalTranspose:n,multidimensionalInfo:s}=o;let{transposedVariableName:l}=t;const a=null!=s&&n&&(null!=r||x(i));if(a&&!l){l=null!=i&&i.length>0?i[0].variableName??void 0:s.variables[0].name,t={...t,transposedVariableName:l}}t=this._getRequestOptionsWithSliceId(t);const{spatialReference:c,extent:h}=o,{datumTransformation:d}=t;let y=L(e,c,d);if(!h.intersects(y))return{location:y,value:null};if(null!=o.transform){const e=o.transform.inverseTransform(y);if(!o.nativeExtent.intersects(e))return{location:e,value:null};y=e}const g=null!=l&&null!=s&&o.hasMultidimensionalTranspose;if(p(this)){const e=this.primaryRasters.rasters[0];if(g)return e.identify(y,t);const{pixelSize:r}=o,n=3,s=r.x*n/2,l=r.y*n/2,a=new u({xmin:y.x-s,xmax:y.x+s,ymin:y.y-l,ymax:y.y+l,spatialReference:c}),f={interpolation:"nearest",multidimensionalDefinition:i,sliceId:t.sliceId,bandIds:t.bandIds},{pixelBlock:m}=await e.fetchPixels(a,n,n,f),{pixelBlock:h}=await this.fetchPixels(a,n,n,f);if(null==m)return{location:y,value:null};const p=Math.floor(n*n*.5),d=!m.mask||m.mask[p]?m.pixels.map(e=>e[p]):null;let x;return null!=h&&(x=!h.mask||h.mask[p]?h.pixels.map(e=>e[p]):void 0),{location:y,value:d,processedValue:x,pyramidLevel:0}}let I=0;if(!g){let{srcResolution:i}=t;if(i){i.spatialReference&&(i=B(new m(i),c));I=j(i,o,this.ioConfig.sampling).pyramidLevel}else if(I=await this.computeBestPyramidLevelForLocation(e,t),null==I)return{location:y,value:null}}const w=this.identifyPixelLocation(y,I,null,g);if(null===w)return{location:y,value:null};const{row:R,col:S,rowOffset:k,colOffset:b,blockWidth:T}=w,v=await this._fetchRawTile(I,R,S,t);if(!v?.pixels?.length)return{location:y,value:null};const P=k*T+b;return this._processIdentifyResult(v,{srcLocation:y,position:P,pyramidLevel:I,useTransposedTile:!!g,requestSomeSlices:a,identifyOptions:t})}async fetchPixels(e,t,i,r={}){e=E(e),r=this._getRequestOptionsWithSliceId(r);const{_hasNoneOrGCSShiftTransform:o}=this;if(r.requestRawData&&o)return this._fetchPixels(e,t,i,r);const n=H(e.spatialReference),s=D(e);if(null==n||0===s||1===s&&this._isGlobalWrappableSource&&o)return this._fetchPixels(e,t,i,r);if(s>=3)return{extent:e,pixelBlock:null};const l=[],{xmin:a,xmax:c}=e,f=Math.round(n/(c-a)*t),m=f-Math.round((n/2-a)/(c-a)*t);let h=0;const p=[];for(let g=0;g<=s;g++){const o=new u({xmin:0===g?a:-n/2,xmax:g===s?c-n*g:n/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),d=0===g?f-m:g===s?t-h:f;h+=d,p.push(d);const x=r.disableWrapAround&&g>0?null:this._fetchPixels(o,d,i,r);l.push(x)}const d=(await Promise.all(l)).map(e=>e?.pixelBlock);let x=null;const y={width:t,height:i};if(this.rasterJobHandler){x=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:d,srcMosaicSize:y,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:p},r)).pixelBlock}else x=_(d,y,{blockWidths:p});return{extent:e,srcExtent:O(e,this.rasterInfo.spatialReference,r.datumTransformation),pixelBlock:x}}async fetchRawPixels(e,t,i,r={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const o=await this._fetchRawTiles(e,t,i,r),{nativeExtent:n,nativePixelSize:s,storageInfo:l}=this.rasterInfo,a=2**e,c=s.x*a,f=s.y*a,m=new u({xmin:n.xmin+c*t.x,xmax:n.xmin+c*(t.x+i.width-1),ymin:n.ymax-f*(t.y+i.height-1),ymax:n.ymax-f*t.y,spatialReference:n.spatialReference});if(!o)return{extent:m,srcExtent:m,pixelBlock:null};const{pixelBlocks:h,mosaicSize:p}=o;if(1===h.length&&null!=h[0]&&h[0].width===i.width&&h[0].height===i.height)return{extent:m,srcExtent:m,pixelBlock:o.pixelBlocks[0]};const d=e>0?l.pyramidBlockWidth:l.blockWidth,x=e>0?l.pyramidBlockHeight:l.blockHeight,y={x:t.x%d,y:t.y%x};let g;if(this.rasterJobHandler){g=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:h,srcMosaicSize:p,destDimension:i,clipOffset:y,clipSize:i,coefs:null,sampleSpacing:null,interpolation:r.interpolation,alignmentInfo:null,blockWidths:null},r)).pixelBlock}else g=_(h,p,{clipOffset:y,clipSize:i});return{extent:m,srcExtent:m,pixelBlock:g}}fetchRawTile(e,t,r,o){throw new i("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return O(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return this.rasterJobHandler?this.rasterJobHandler.decode({data:e,options:t}):P(e,t)}async request(e,i,r=0){const{customFetchParameters:o}=this.ioConfig,{range:n,query:s,headers:l}=i;r=r??i.retryCount??this.ioConfig.retryCount;const a=n?{Range:`bytes=${n.from}-${n.to}`}:null;try{return await t(e,{...i,query:{...s,...o},headers:{...l,...a}})}catch(c){if(r>0)return r--,this.request(e,i,r);throw c}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:y(e,t)}getTileExtentFromTileInfo(e,t,i,r){const o=r.lodAt(e);return o?this.getTileExtent({x:o.resolution,y:o.resolution},t,i,r.origin,r.spatialReference,r.size):null}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:r}=this.rasterInfo,{pyramidResolutions:o}=e;if(!e.tileInfo){const n=[],s=e.maximumPyramidLevel||0;let l=(r.x+r.y)/2,a=1/.0254*96*l;for(let e=0;e<=s&&(n.unshift(new Q({level:s-e,resolution:l,scale:a})),e!==s);e++)if(o){const t=(o[e].x+o[e].y)/2;a*=t/l,l=t}else l*=2,a*=2;const c=new m({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new X({origin:c,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:n}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,r){const{width:o,height:n,nativeExtent:s,pixelSize:l,spatialReference:a}=e,c=new m({x:s.xmin,y:s.ymax,spatialReference:a});null==r&&(r=Math.max(0,Math.round(Math.log(Math.max(o,n))/Math.LN2-8)));const f=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[l],r);e.storageInfo=new $({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:r,blockBoundary:f})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,r,o,n=0,s=2){if(1===o.length&&n>0){o=[...o];let{x:e,y:t}=o[0];for(let i=0;i<n;i++)e*=s,t*=s,o.push({x:e,y:t})}const l=[],{x:a,y:c}=r;for(let f=0;f<o.length;f++){const{x:r,y:n}=o[f];l.push({minCol:Math.floor((e.xmin-a+.1*r)/t/r),maxCol:Math.floor((e.xmax-a-.1*r)/t/r),minRow:Math.floor((c-e.ymax+.1*n)/i/n),maxRow:Math.floor((c-e.ymin-.1*n)/i/n)})}return l}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:i,pyramidScalingFactor:r}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=i&&i.length)return i[e-1];const o=r**e;return{x:t.x*o,y:t.y*o}}identifyPixelLocation(e,t,i,r){const{spatialReference:o,nativeExtent:n,storageInfo:s}=this.rasterInfo,{maximumPyramidLevel:l,origin:a,transposeInfo:c}=s,f=r&&null!=c?c.tileSize[0]:s.blockWidth,u=r&&null!=c?c.tileSize[1]:s.blockHeight,m=L(e,o,i);if(!n.intersects(m))return null;if(t<0||t>l)return null;const h=this.getPyramidPixelSize(t),{x:p,y:d}=h,x=(a.y-m.y)/d/u,y=(m.x-a.x)/p/f,g=Math.min(u-1,Math.floor((x-Math.floor(x))*u)),I=Math.min(f-1,Math.floor((y-Math.floor(y))*f));return{pyramidLevel:t,row:Math.floor(x),col:Math.floor(y),rowOffset:g,colOffset:I,blockWidth:f,srcLocation:m}}getTileExtent(e,t,i,r,o,n){const[s,l]=n,a=r.x+i*s*e.x,c=a+s*e.x,f=r.y-t*l*e.y,m=f-l*e.y;return new u({xmin:a,xmax:c,ymin:m,ymax:f,spatialReference:o})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,i){const r=this.rasterInfo.storageInfo.blockBoundary[e];return!r||r.maxRow<t||r.maxCol<i||r.minRow>t||r.minCol>i}updateImageSpaceRasterInfo(e){const{pixelSize:t}=e,{width:i,height:r}=e,o=h.WebMercator;e.spatialReference=o,e.extent=e.nativeExtent=new u({xmin:-.5,ymax:.5,xmax:i-.5,ymin:.5-r,spatialReference:o}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new m({x:1,y:1,spatialReference:o});const{extent:n,storageInfo:s}=e;if(s){s.origin=new m({x:n.xmin,y:n.ymax,spatialReference:o});const{pyramidResolutions:i,tileInfo:r}=s;if(i&&i.forEach(e=>{e.x/=t.x,e.y/=t.y}),r){r.origin=s.origin;const t=(e.nativePixelSize.x+e.nativePixelSize.y)/2;r.lods.forEach((e,i)=>{e.resolution=t*2**i,e.scale=96*e.resolution/.0254})}}}async _refresh(e){return{dataChanged:!0}}async _fetchPixels(e,t,i,r={}){let o=D(e);if(o>=2)return{extent:e,pixelBlock:null};const n=this._getSourceDataInfo(e,t,i,r),{pyramidLevel:s,srcResolution:l,srcWidth:a,srcHeight:c,ul:f}=n;let{srcExtent:u}=n;if(0===a||0===c)return{extent:e,srcExtent:u,pixelBlock:null};const{rasterInfo:h}=this,p=h.transform,d="gcs-shift"===p?.type,x=null!=H(e.spatialReference);!d&&x||(o=D(u,d));const y=await this._fetchRawTiles(s,f,{width:a,height:c,wrapCount:o},r);if(!y)return{extent:e,srcExtent:u,pixelBlock:null};u=y.extent;const g=h.storageInfo,I=s>0?g.pyramidBlockWidth:g.blockWidth,w=s>0?g.pyramidBlockHeight:g.blockHeight;let{x:R,y:S}=h.pixelSize;if(s>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=g;if(null!=e&&e[s-1])({x:R,y:S}=e[s-1]);else{const e=t**s;R*=e,S*=e}}const k=h.spatialReference,b=new m({x:R,y:S,spatialReference:k}),T=I===a&&w===c&&f.x%I===0&&f.y%w===0,v=new m({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),P=!e.spatialReference.equals(k),B=k.isGeographic?1e-9:1e-4,{datumTransformation:C}=r;if(!P&&T&&1===y.pixelBlocks.length&&I===t&&w===i&&te(l,v,B))return{extent:e,srcExtent:u,srcTilePixelSize:b,pixelBlock:y.pixelBlocks[0]};const L=x&&null!=H(u.spatialReference)&&this._hasNoneOrGCSShiftTransform,j=r.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");j&&!this.rasterJobHandler&&await z();const E=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:u,pixelSize:v.toJSON(),datumTransformation:C,rasterTransform:p,hasWrapAround:o>0||L,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:j},r):A({projectedExtent:e,srcBufferExtent:u,pixelSize:v,datumTransformation:C,rasterTransform:p,hasWrapAround:o>0||L,isAdaptive:!1,includeGCSGrid:j});let O;const q=!r.requestRawData,F={rows:E.spacing[0],cols:E.spacing[1]},J=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(s,u.xmin):void 0,{pixelBlocks:N,mosaicSize:V,isPartiallyFilled:U}=y;let Q=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:N,srcMosaicSize:V,destDimension:q?{width:t,height:i}:null,coefs:q?E.coefficients:null,sampleSpacing:q?F:null,projectDirections:j,gcsGrid:j?E.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:r.interpolation,alignmentInfo:J,blockWidths:null},r);({pixelBlock:O,localNorthDirections:Q}=e)}else{const e=_(N,V,{alignmentInfo:J});O=q?M(e,{width:t,height:i},E.coefficients,F,r.interpolation):e,j&&E.gcsGrid&&(Q=W({width:t,height:i},E.gcsGrid),O=G(O,this.rasterInfo.dataType,Q))}return r.requestRawData||j?{extent:e,srcExtent:u,srcTilePixelSize:b,pixelBlock:O,transformGrid:E,localNorthDirections:Q,isPartiallyFilled:U}:{extent:e,srcExtent:e,srcTilePixelSize:b,pixelBlock:O}}async _fetchRawTiles(e,t,i,r){const{origin:o,blockBoundary:n}=this.rasterInfo.storageInfo,{blockWidth:s,blockHeight:l}=this.getBlockWidthHeight(e);let{x:a,y:c}=t,{width:f,height:m,wrapCount:h}=i;const p=this._getRasterTileAlignmentInfo(e,0);r.buffer&&(a-=r.buffer.cols,c-=r.buffer.rows,f+=2*r.buffer.cols,m+=2*r.buffer.rows);let d=0,x=0,y=0;if(h&&null!=p){({worldColumnCountFromOrigin:x,originColumnOffset:y,rightPadding:d}=p);x*p.blockWidth-d>=a+f&&(d=0)}const g=Math.floor(a/s),I=Math.floor(c/l),w=Math.floor((a+f+d-1)/s),R=Math.floor((c+m+d-1)/l),S=n[e];if(!S)return null;const{minRow:k,minCol:b,maxCol:T,maxRow:v}=S;if(0===h&&(R<k||w<b||I>v||g>T))return null;const P=new Array;let B=!1;const _=null==this.ioConfig.allowPartialFill?r.allowPartialFill:this.ioConfig.allowPartialFill;for(let u=I;u<=R;u++)for(let t=g;t<=w;t++){let i=t;if(!r.disableWrapAround&&h&&null!=p&&x<=t&&(i=t-x-y),u>=k&&i>=b&&v>=u&&T>=i){const t=this._fetchRawTile(e,u,i,r);_?P.push(new Promise(e=>{t.then(t=>e(t)).catch(()=>{B=!0,e(null)})})):P.push(t)}else P.push(Promise.resolve(null))}if(0===P.length)return null;const M=await Promise.all(P),W={height:(R-I+1)*l,width:(w-g+1)*s},{spatialReference:C}=this.rasterInfo,H=this.getPyramidPixelSize(e),{x:z,y:L}=H;return{extent:new u({xmin:o.x+g*s*z,xmax:o.x+(w+1)*s*z,ymin:o.y-(R+1)*l*L,ymax:o.y-I*l*L,spatialReference:C}),pixelBlocks:M,mosaicSize:W,isPartiallyFilled:B}}_fetchRawTile(e,t,i,r){const{storageInfo:o}=this.rasterInfo,n=null!=o.transposeInfo&&!!r.transposedVariableName;if(!n){const r=o.blockBoundary[e];if(!r)return Promise.resolve(null);const{minRow:n,minCol:s,maxCol:l,maxRow:a}=r;if(t<n||i<s||t>a||i>l)return Promise.resolve(null)}const l=n?r.transposeVariableName:r.sliceId,a=o.isBsqTile?r.bandIds:null,c=R(this.rasterId,l,a),f=`${e}/${t}/${i}`;let u=S(c,r.registryId,f);if(null==u){const n=new AbortController,s=r.bandIds?.slice();if(s?.length&&o.isBsqTile){const o=new Set(s),l=[],a=Array.from(o);for(const s of a)l.push(this._tileFetchQueue.push({pyramidLevel:e,row:t,col:i,options:{...r,bandIds:[s]}},{signal:n.signal}));u=Promise.all(l).then(e=>{if(e.some(e=>null==e))return null;if(a.length!==s.length){const t=[];for(const i of s){let r=e[a.indexOf(i)];t.includes(r)&&(r=r.clone()),t.push(r)}e=t}return this.rasterJobHandler?this.rasterJobHandler.compositeBands({pixelBlocks:e},{signal:n.signal,transferPixelsToWorker:!0}):C(e)})}else u=this._tileFetchQueue.push({pyramidLevel:e,row:t,col:i,options:r},{signal:n.signal});k(c,r.registryId,f,u,n),u.catch(()=>b(c,r.registryId,f))}return r.signal&&s(r,()=>{T(c,r.registryId,f)}),u}_computeMagDirValues(e){const{bandCount:t,dataType:i}=this.rasterInfo;if(!(2===t&&"vector-magdir"===i||"vector-uv"===i)||2!==e?.length||!e[0]?.length)return null;const r=e[0].length;if("vector-magdir"===i){const t=e[1].map(e=>(e+360)%360);return[e[0],t]}const[o,n]=e,s=[],l=[];for(let a=0;a<r;a++){const[e,t]=J([o[a],n[a]]);s.push(e),l.push(t)}return[s,l]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlignmentInfo&&(this._rasterTileAlignmentInfo=q(this.rasterInfo)),null==this._rasterTileAlignmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,i,r={}){const o={datumTransformation:r.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};r.srcResolution&&(o.srcResolution=r.srcResolution,this._updateSourceDataInfo(e,o));const n=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:s,srcHeight:l,pyramidLevel:a}=o,c=s/t,f=l/i,u=a<n&&c*f>=16,h=a===n&&this._requireTooManySrcTiles(s,l,t,i);if(u||h||(0===s||0===l)){const s=new m({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference});let l=F(s,this.rasterInfo.spatialReference,e,o.datumTransformation);const h=!l||r.srcResolution&&l.x+l.y<r.srcResolution.x+r.srcResolution.y;if(u&&r.srcResolution&&h){const e=Math.round(Math.log(Math.max(c,f))/Math.LN2)-1;if(n-a+3>=e){const t=2**e;l={x:r.srcResolution.x*t,y:r.srcResolution.y*t}}}l&&(o.srcResolution=l,this._updateSourceDataInfo(e,o))}return this._requireTooManySrcTiles(o.srcWidth,o.srcHeight,t,i)&&(o.srcWidth=0,o.srcHeight=0),o}_requireTooManySrcTiles(e,t,i,r){const{tileInfo:o}=this.rasterInfo.storageInfo,n=Math.ceil(e/o.size[0])*Math.ceil(t/o.size[1]),s=e/i,l=t/r,a=Math.max(1,(i+r)/1024);return n>=Y*a||s>K||l>K}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,r=i.spatialReference,{srcResolution:o,datumTransformation:n}=t,{pyramidLevel:s,pyramidResolution:l,excessiveReading:a}=j(o,i,this.ioConfig.sampling);if(a)return;let c=t.srcExtent||O(e,r,n);if(null==c)return;const f=i.transform;f&&(c=f.inverseTransform(c)),t.srcExtent=c;const{origin:u}=i.storageInfo,{width:m,height:h,ul:p}=d(c,u,l,s);t.pyramidLevel=s,t.pyramidResolution=l,t.srcWidth=m,t.srcHeight=h,t.ul=p}_getRequestOptionsWithSliceId(e){return null!=this.rasterInfo.multidimensionalInfo&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:i,position:r,pyramidLevel:o,useTransposedTile:n}=t,s=e.pixels[0].length/e.width/e.height;if(!(!e.mask||e.mask[r]))return{location:i,value:null};const{multidimensionalInfo:l}=this.rasterInfo;if(null==l||!n){const t=e.pixels.map(e=>e[r]),n={location:i,value:t,pyramidLevel:o},s=this._computeMagDirValues(t.map(e=>[e]));return s?.length&&(n.magdirValue=s.map(e=>e[0])),n}let a=e.pixels.map(e=>e.slice(r*s,r*s+s)),c=this._computeMagDirValues(a);const{requestSomeSlices:f,identifyOptions:u}=t;let m=g(l,u.transposedVariableName);if(f){const e=I(m,u.multidimensionalDefinition,u.timeExtent);a=a.map(t=>e.map(e=>t[e])),c=c?.map(t=>e.map(e=>t[e])),m=e.map(e=>m[e])}const h=e.noDataValues||this.rasterInfo.noDataValue,p={pixels:a,pixelType:e.pixelType};let d;null!=h&&(v(p,h),d=p.mask);return{location:i,value:null,dataSeries:m.map((e,t)=>{const i={value:0===d?.[t]?null:a.map(e=>e[t]),multidimensionalDefinition:e.multidimensionalDefinition.map(e=>new U({...e,isSlice:!0}))};return c?.length&&(i.magdirValue=[c[0][t],c[1][t]]),i}),pyramidLevel:o}}};function te(e,t,i){return Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i}e([a()],ee.prototype,"_rasterTileAlignmentInfo",void 0),e([a()],ee.prototype,"_tileFetchQueue",void 0),e([a({readOnly:!0})],ee.prototype,"_isGlobalWrappableSource",null),e([a({readOnly:!0})],ee.prototype,"_hasNoneOrGCSShiftTransform",null),e([a()],ee.prototype,"_openPromise",void 0),e([a()],ee.prototype,"rasterJobHandler",null),e([a({readOnly:!0})],ee.prototype,"rasterId",null),e([a(V)],ee.prototype,"url",null),e([a({type:String,json:{write:!0}})],ee.prototype,"datasetName",void 0),e([a({type:String,json:{write:!0}})],ee.prototype,"datasetFormat",void 0),e([a()],ee.prototype,"hasUniqueSourceStorageInfo",void 0),e([a()],ee.prototype,"rasterInfo",void 0),e([a()],ee.prototype,"ioConfig",void 0),e([a()],ee.prototype,"sourceJSON",void 0),e([a()],ee.prototype,"rawBlockRegistryIds",void 0),ee=e([c("esri.layers.raster.datasets.BaseRaster")],ee);export{ee as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{saveAs as e,save as r}from"./utils.js";import{createForItemWrite as t}from"../../portal/support/jsonContext.js";import{typeKeyword as o,hasTypeKeyword as s,removeTypeKeyword as a,addTypeKeyword as n,toggleTypeKeyword as i}from"../../portal/support/portalItemUtils.js";import{saveResources as u}from"../../webdoc/support/resourceUtils.js";import{hasCharts as c}from"../../webdoc/support/saveUtils.js";const p="Group Layer",l="group-layer-save",m="group-layer-save-as",y=o.GROUP_LAYER_MAP;function f(e){return{isValid:"group"===e.type,errorMessage:"Layer.type should be 'group'"}}function v(e){return{isValid:s(e,y),errorMessage:`Layer.portalItem.typeKeywords should have '${y}'`}}function d(e,r){return{...t(e,"web-map",!0),initiator:r}}function I(e){const r=e.layerJSON;return Promise.resolve(r&&Object.keys(r).length?r:null)}function A(e,r){i(r,o.CHARTS,c(e))}function P(e,r){A(e,r)}async function R(e,r){r.title||=e.title,a(r,o.METADATA),n(r,y),A(e,r)}async function g(e,t){return r({layer:e,itemType:p,validateLayer:f,validateItem:v,createJSONContext:r=>d(r,e),createItemData:I,errorNamePrefix:l,setItemProperties:P,saveResources:async(r,t)=>(e.sourceIsPortalItem||await r.removeAllResources().catch(()=>{}),u(e.resourceReferences,t))},t)}async function j(r,t,o){return e({layer:r,itemType:p,validateLayer:f,createJSONContext:e=>d(e,r),createItemData:I,errorNamePrefix:m,newItem:t,setItemProperties:R,saveResources:(e,t)=>u(r.resourceReferences,t)},o)}export{g as save,j as saveAs};
2
+ import{saveAs as e,save as r}from"./utils.js";import{createForItemWrite as t}from"../../portal/support/jsonContext.js";import{typeKeyword as o,hasTypeKeyword as s,removeTypeKeyword as a,addTypeKeyword as n,toggleTypeKeyword as i}from"../../portal/support/portalItemUtils.js";import{saveResources as u}from"../../webdoc/support/resourceUtils.js";import{hasCharts as c}from"../../webdoc/support/saveUtils.js";const p="Group Layer",l="group-layer-save",m="group-layer-save-as",y=o.GROUP_LAYER_MAP;function f(e){return{isValid:"group"===e.type,errorMessage:"Layer.type should be 'group'"}}function v(e){return{isValid:s(e,y),errorMessage:`Layer.portalItem.typeKeywords should have '${y}'`}}function d(e,r){return{...t(e,"web-map",{withResources:!0}),initiator:r}}function I(e){const r=e.layerJSON;return Promise.resolve(r&&Object.keys(r).length?r:null)}function R(e,r){i(r,o.CHARTS,c(e))}function A(e,r){R(e,r)}async function P(e,r){r.title||=e.title,a(r,o.METADATA),n(r,y),R(e,r)}async function g(e,t){return r({layer:e,itemType:p,validateLayer:f,validateItem:v,createJSONContext:r=>d(r,e),createItemData:I,errorNamePrefix:l,setItemProperties:A,saveResources:async(r,t)=>(e.sourceIsPortalItem||await r.removeAllResources().catch(()=>{}),u(e.resourceReferences,t))},t)}async function j(r,t,o){return e({layer:r,itemType:p,validateLayer:f,createJSONContext:e=>d(e,r),createItemData:I,errorNamePrefix:m,newItem:t,setItemProperties:P,saveResources:(e,t)=>u(r.resourceReferences,t)},o)}export{g as save,j as saveAs};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{saveAs as e,save as r}from"./utils.js";import{createForItemWrite as t}from"../../portal/support/jsonContext.js";import{getWGS84ExtentForItem as a,removeTypeKeyword as s,typeKeyword as o}from"../../portal/support/portalItemUtils.js";import{saveResources as n}from"../../webdoc/support/resourceUtils.js";const i="Media Layer",u="media-layer-save",p="media-layer-save-as",l=["media-layer:unsupported-source"];function m(e){return{isValid:"media"===e.type,errorMessage:"Layer.type should be 'media'"}}function c(e){return t(e,"portal-item",!0)}function y(e){return Promise.resolve(e.layerJSON)}async function f(e,r){r.extent=e.fullExtent?await a(e.fullExtent):null}async function d(e,r){r.title||=e.title,await f(e,r),s(r,o.METADATA)}async function v(e,t){return r({layer:e,itemType:i,validateLayer:m,createJSONContext:e=>c(e),createItemData:y,errorNamePrefix:u,supplementalUnsupportedErrors:l,setItemProperties:f,saveResources:(r,t)=>n(e.resourceReferences,t)},t)}async function x(r,t,a){return e({layer:r,itemType:i,validateLayer:m,createJSONContext:e=>c(e),createItemData:y,errorNamePrefix:p,supplementalUnsupportedErrors:l,newItem:t,setItemProperties:d,saveResources:(e,t)=>n(r.resourceReferences,t)},a)}export{v as save,x as saveAs};
2
+ import{saveAs as e,save as r}from"./utils.js";import{createForItemWrite as t}from"../../portal/support/jsonContext.js";import{getWGS84ExtentForItem as a,removeTypeKeyword as s,typeKeyword as o}from"../../portal/support/portalItemUtils.js";import{saveResources as n}from"../../webdoc/support/resourceUtils.js";const i="Media Layer",u="media-layer-save",p="media-layer-save-as",l=["media-layer:unsupported-source"];function m(e){return{isValid:"media"===e.type,errorMessage:"Layer.type should be 'media'"}}function c(e){return t(e,"portal-item",{withResources:!0})}function y(e){return Promise.resolve(e.layerJSON)}async function f(e,r){r.extent=e.fullExtent?await a(e.fullExtent):null}async function d(e,r){r.title||=e.title,await f(e,r),s(r,o.METADATA)}async function v(e,t){return r({layer:e,itemType:i,validateLayer:m,createJSONContext:e=>c(e),createItemData:y,errorNamePrefix:u,supplementalUnsupportedErrors:l,setItemProperties:f,saveResources:(r,t)=>n(e.resourceReferences,t)},t)}async function x(r,t,a){return e({layer:r,itemType:i,validateLayer:m,createJSONContext:e=>c(e),createItemData:y,errorNamePrefix:p,supplementalUnsupportedErrors:l,newItem:t,setItemProperties:d,saveResources:(e,t)=>n(r.resourceReferences,t)},a)}export{v as save,x as saveAs};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- class t{constructor(t){this._store=t}destroy(){this._store.destroy()}get(t){return this._store.get(t)}put(t,s){this._store.put(t,s)}}export{t as ElevationQueryTileCache};
2
+ class t{constructor(t){this._store=t}destroy(){this._store.destroy()}get(t){return this._store.get(t)}put(t,s){this._store.put(t,s)}clear(){this._store.clear()}}export{t as ElevationQueryTileCache};
@@ -1,3 +1,6 @@
1
+ import type Polygon from "../../geometry/Polygon.js";
2
+ import type Polyline from "../../geometry/Polyline.js";
3
+
1
4
  /**
2
5
  * Defines the possible states of a video layer.
3
6
  *
@@ -113,7 +116,20 @@ export interface LivestreamStatus {
113
116
  *
114
117
  * @since 5.1
115
118
  */
116
- export interface Coverage {}
119
+ export interface Coverage {
120
+ /**
121
+ * A single polygon dataset representing the geometric union of all individual video frame extents collected over the duration of the video collection.
122
+ *
123
+ * @since 5.1
124
+ */
125
+ area?: Polygon | null;
126
+ /**
127
+ * A single polyline representing the continuous spatial path traveled by the collecting sensor.
128
+ *
129
+ * @since 5.1
130
+ */
131
+ path?: Polyline | null;
132
+ }
117
133
 
118
134
  /**
119
135
  * Defines an object that contains metadata defining layer previews information.
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{serializeInclusionDefinitionToEntitiesPbf as e,serializeInclusionDefinitionToRelationshipsPbf as r}from"../applications/KnowledgeStudio/resourceSerializationUtils.js";import{Clonable as i}from"../core/Clonable.js";import{MultiOriginJSONSupportMixin as o}from"../core/MultiOriginJSONSupport.js";import{join as s}from"../core/urlUtils.js";import{generateUUID as n}from"../core/uuid.js";import{property as a,subclass as l}from"../core/accessorSupport/decorators.js";import{nameToId as p}from"../core/accessorSupport/PropertyOrigin.js";import{getRelationshipEndNodeMap as u}from"../layers/knowledgeGraph/supportUtils.js";import{layoutTypes as c}from"./enums.js";import h from"./LayoutSettings.js";import d from"./NonspatialDataDisplay.js";import{areResourcesSafe as m}from"./utils.js";import{f as y,t as U}from"../chunks/persistableUrlUtils.js";import{reader as g}from"../core/accessorSupport/decorators/reader.js";import{writer as f}from"../core/accessorSupport/decorators/writer.js";let w=class extends(o(i)){constructor(t){super(t),this.aggregatedEntitiesUrl=null,this.aggregatedRelationshipsUrl=null,this.autoCollapseRelationships=!0,this.centralityIsUpToDate=!0,this.entitiesUrl=null,this.layoutSettings=null,this.layoutType="organic-standard",this.nonspatialDataDisplay=null,this.relationshipsUrl=null,this._entitiesResourceCreationDate=null,this._relationshipsResourceCreationDate=null}readEntitiesUrl(t,e,r){return y(t,r)}writeEntitiesUrl(t,e,r,i){e[r]="<pending>",i?.resources?.pendingOperations.push(new Promise((o,s)=>{this._writeResourceUrl(t,e,r,i,o,s)}))}readRelationshipsUrl(t,e,r){return y(t,r)}writeRelationshipsUrl(t,e,r,i){e[r]="<pending>",i?.resources?.pendingOperations.push(new Promise((o,s)=>{this._writeResourceUrl(t,e,r,i,o,s)}))}setCreationDatesForResources(t){if(this.entitiesUrl){const e=t.get(this.entitiesUrl);"number"==typeof e&&(this._entitiesResourceCreationDate=e)}if(this.relationshipsUrl){const e=t.get(this.relationshipsUrl);"number"==typeof e&&(this._relationshipsResourceCreationDate=e)}}async _writeResourceUrl(t,e,r,i,o,s){try{const n=i?.portalItem,a=i?.resources,l=p(i?.origin),u=i?.webmap?.activeLinkChartLayer,c="entitiesUrl"===r?this._entitiesResourceCreationDate:this._relationshipsResourceCreationDate,h=await m(t??"",n?.itemUrl??"","number"==typeof c?c:void 0);if(!n||!a||null==l||!u||!u.membershipModified&&n.id&&h)return t&&(e[r]=U(t,i)),void o();this._saveUrlAsNewResource(e,r,a,n,u,o,s)}catch(n){s(n)}}_saveUrlAsNewResource(t,e,r,i,o,s,n){const a=(o.knowledgeGraph.dataModel.relationshipTypes??[]).map(t=>t.name).reduce((t,e)=>{if(!e)return t;const{members:r}=o.dataManager.inclusionModeDefinition.namedTypeDefinitions.get(e)||{members:void 0};if(!r)return t;for(const[i]of r)t.push({id:i,typeName:e});return t},[]);u(a,o.knowledgeGraph).then(a=>{D(o.dataManager.inclusionModeDefinition,e,o.knowledgeGraph,a).then(o=>{const n=R(i,"entitiesUrl"===e?"entitiesUrl":"relationshipsUrl");t[e]=n.itemRelativeUrl,r.toAdd.push({resource:n,content:{type:"blob",blob:o},compress:!1,finish:t=>{"entitiesUrl"===e?this.entitiesUrl=t.url:this.relationshipsUrl=t.url}}),s()}).catch(t=>{n(t)})}).catch(t=>{n(t)})}};t([a({type:String,json:{write:!0}})],w.prototype,"aggregatedEntitiesUrl",void 0),t([a({type:String,json:{write:!0}})],w.prototype,"aggregatedRelationshipsUrl",void 0),t([a({type:Boolean,json:{write:!0}})],w.prototype,"autoCollapseRelationships",void 0),t([a({type:Boolean,json:{write:!0}})],w.prototype,"centralityIsUpToDate",void 0),t([a({type:String,json:{write:{ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],w.prototype,"entitiesUrl",void 0),t([g("entitiesUrl")],w.prototype,"readEntitiesUrl",null),t([f("entitiesUrl")],w.prototype,"writeEntitiesUrl",null),t([a({type:h,json:{write:!0}})],w.prototype,"layoutSettings",void 0),t([a({type:c,json:{write:!0}})],w.prototype,"layoutType",void 0),t([a({type:d,json:{write:!0}})],w.prototype,"nonspatialDataDisplay",void 0),t([a({type:String,json:{write:{ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],w.prototype,"relationshipsUrl",void 0),t([g("relationshipsUrl")],w.prototype,"readRelationshipsUrl",null),t([f("relationshipsUrl")],w.prototype,"writeRelationshipsUrl",null),w=t([l("esri.linkChart.LinkChartProperties")],w);const j=w;function R(t,e){const r=`${e}-${n()}.dat`,i=s("linkChart",r);return t.resourceFromPath(i)}async function D(t,i,o,s){let n;return n="entitiesUrl"===i?await e(t,o,s):await r(t,o,s),new Blob([n],{type:"application/x-protobuf"})}export{j as default};
2
+ import{__decorate as t}from"tslib";import{serializeInclusionDefinitionToEntitiesPbf as e,serializeInclusionDefinitionToRelationshipsPbf as r}from"../applications/KnowledgeStudio/resourceSerializationUtils.js";import{Clonable as i}from"../core/Clonable.js";import{MultiOriginJSONSupportMixin as o}from"../core/MultiOriginJSONSupport.js";import{isAbsolute as s,join as n}from"../core/urlUtils.js";import{generateUUID as a}from"../core/uuid.js";import{property as l,subclass as p}from"../core/accessorSupport/decorators.js";import{nameToId as u}from"../core/accessorSupport/PropertyOrigin.js";import{getRelationshipEndNodeMap as c}from"../layers/knowledgeGraph/supportUtils.js";import{layoutTypes as h}from"./enums.js";import d from"./LayoutSettings.js";import m from"./NonspatialDataDisplay.js";import{areResourcesSafe as y}from"./utils.js";import{f as U,t as g}from"../chunks/persistableUrlUtils.js";import{reader as f}from"../core/accessorSupport/decorators/reader.js";import{writer as w}from"../core/accessorSupport/decorators/writer.js";let j=class extends(o(i)){constructor(t){super(t),this.aggregatedEntitiesUrl=null,this.aggregatedRelationshipsUrl=null,this.autoCollapseRelationships=!0,this.centralityIsUpToDate=!0,this.entitiesUrl=null,this.layoutSettings=null,this.layoutType="organic-standard",this.nonspatialDataDisplay=null,this.relationshipsUrl=null,this._entitiesResourceCreationDate=null,this._relationshipsResourceCreationDate=null}readEntitiesUrl(t,e,r){return U(t,r)}writeEntitiesUrl(t,e,r,i){e[r]="<pending>",i?.resources?.pendingOperations.push(new Promise((o,s)=>{this._writeResourceUrl(t,e,r,i,o,s)}))}readRelationshipsUrl(t,e,r){return U(t,r)}writeRelationshipsUrl(t,e,r,i){e[r]="<pending>",i?.resources?.pendingOperations.push(new Promise((o,s)=>{this._writeResourceUrl(t,e,r,i,o,s)}))}setCreationDatesForResources(t){if(this.entitiesUrl){const e=t.get(this.entitiesUrl);"number"==typeof e&&(this._entitiesResourceCreationDate=e)}if(this.relationshipsUrl){const e=t.get(this.relationshipsUrl);"number"==typeof e&&(this._relationshipsResourceCreationDate=e)}}async _writeResourceUrl(t,e,r,i,o,n){try{const a=i?.portalItem,l=i?.resources,p=u(i?.origin),c=i?.webmap?.activeLinkChartLayer;if(!a||!l||null==p||!c)return t&&(e[r]=g(t,i)),void o();if(c.membershipModified||!a.id)return void this._saveUrlAsNewResource(e,r,l,a,c,o,n);const h="entitiesUrl"===r?this._entitiesResourceCreationDate:this._relationshipsResourceCreationDate;if(await y(t??"",a?.itemUrl??"","number"==typeof h?h:void 0)){if(t){const p=g(t,i);if(s(p))return void this._saveUrlAsNewResource(e,r,l,a,c,o,n);e[r]=p}return void o()}this._saveUrlAsNewResource(e,r,l,a,c,o,n)}catch(a){n(a)}}_saveUrlAsNewResource(t,e,r,i,o,s,n){const a=(o.knowledgeGraph.dataModel.relationshipTypes??[]).map(t=>t.name).reduce((t,e)=>{if(!e)return t;const{members:r}=o.dataManager.inclusionModeDefinition.namedTypeDefinitions.get(e)||{members:void 0};if(!r)return t;for(const[i]of r)t.push({id:i,typeName:e});return t},[]);c(a,o.knowledgeGraph).then(a=>{D(o.dataManager.inclusionModeDefinition,e,o.knowledgeGraph,a).then(o=>{const n=v(i,"entitiesUrl"===e?"entitiesUrl":"relationshipsUrl");t[e]=n.itemRelativeUrl,r.toAdd.push({resource:n,content:{type:"blob",blob:o},compress:!1,finish:t=>{"entitiesUrl"===e?this.entitiesUrl=t.url:this.relationshipsUrl=t.url}}),s()}).catch(t=>{n(t)})}).catch(t=>{n(t)})}};t([l({type:String,json:{write:!0}})],j.prototype,"aggregatedEntitiesUrl",void 0),t([l({type:String,json:{write:!0}})],j.prototype,"aggregatedRelationshipsUrl",void 0),t([l({type:Boolean,json:{write:!0}})],j.prototype,"autoCollapseRelationships",void 0),t([l({type:Boolean,json:{write:!0}})],j.prototype,"centralityIsUpToDate",void 0),t([l({type:String,json:{write:{ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],j.prototype,"entitiesUrl",void 0),t([f("entitiesUrl")],j.prototype,"readEntitiesUrl",null),t([w("entitiesUrl")],j.prototype,"writeEntitiesUrl",null),t([l({type:d,json:{write:!0}})],j.prototype,"layoutSettings",void 0),t([l({type:h,json:{write:!0}})],j.prototype,"layoutType",void 0),t([l({type:m,json:{write:!0}})],j.prototype,"nonspatialDataDisplay",void 0),t([l({type:String,json:{write:{ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],j.prototype,"relationshipsUrl",void 0),t([f("relationshipsUrl")],j.prototype,"readRelationshipsUrl",null),t([w("relationshipsUrl")],j.prototype,"writeRelationshipsUrl",null),j=t([p("esri.linkChart.LinkChartProperties")],j);const R=j;function v(t,e){const r=`${e}-${a()}.dat`,i=n("linkChart",r);return t.resourceFromPath(i)}async function D(t,i,o,s){let n;return n="entitiesUrl"===i?await e(t,o,s):await r(t,o,s),new Blob([n],{type:"application/x-protobuf"})}export{R as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "5.2.0-next.62",
3
+ "version": "5.2.0-next.63",
4
4
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
5
5
  "keywords": [
6
6
  "ArcGIS",
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{urlToObject as t}from"../../core/urlUtils.js";import r from"../Portal.js";function e(t,r){return{...l(t,r),readResourcePaths:[]}}function o(r,e,o){const i=t(r.itemUrl);return{...l(r,e),messages:[],writtenProperties:[],blockedRelativeUrls:[],verifyItemRelativeUrls:i?{rootPath:i.path,writtenUrls:[]}:null,resources:o?{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}:null}}function l(e,o){return{origin:o,url:t(e.itemUrl),portal:e.portal||r.getDefault(),portalItem:e}}export{e as createForItemRead,o as createForItemWrite};
2
+ import{urlToObject as t}from"../../core/urlUtils.js";import e from"../Portal.js";function r(t,e){return{...l(t,e),readResourcePaths:[]}}function o(e,r,o){const n=t(o?.forceNewItemContext?null:e.itemUrl);return{...l(e,r,o),messages:[],writtenProperties:[],blockedRelativeUrls:[],verifyItemRelativeUrls:n?{rootPath:n.path,writtenUrls:[]}:null,resources:o?.withResources?{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}:null}}function l(r,o,l){return{origin:o,url:t(l?.forceNewItemContext?null:r.itemUrl),portal:r.portal||e.getDefault(),portalItem:r}}export{r as createForItemRead,o as createForItemWrite};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"../kernel.js";import"../core/urlUtils.js";import"../portal/support/urlUtils.js";export{e as ensureMainOnlineDomain,c as fromCDNUrl,f as fromJSON,i as itemIdFromResourceUrl,p as prefixAndFilenameFromResourceUrl,r as read,a as toCDNUrl,t as toJSON,w as write}from"../chunks/persistableUrlUtils.js";
2
+ import"../kernel.js";import"../core/urlUtils.js";import"../portal/support/urlUtils.js";export{e as ensureMainOnlineDomain,d as fromCDNUrl,f as fromJSON,i as itemIdFromResourceUrl,c as itemUrlFromResourceUrl,p as prefixAndFilenameFromResourceUrl,r as read,a as toCDNUrl,t as toJSON,w as write}from"../chunks/persistableUrlUtils.js";
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- const e="20260728",d="4b44fe2decd2d62c4f526e0bf99a7133de541f32";export{e as buildDate,d as commitHash};
2
+ const a="20260729",b="92c714aacf2d388bba22725e11dbd6afb681940a";export{a as buildDate,b as commitHash};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../../../request.js";import t from"../../../../../../core/Error.js";import r from"../../../../../../core/Logger.js";import{notDeepEqual as s}from"../../../../../../core/object.js";import{QueueProcessor as i}from"../../../../../../core/QueueProcessor.js";import a from"../../../../../../rest/support/Query.js";import{FeatureSourceQueryInfo as n}from"../FeatureSourceQueryInfo.js";import{ALoadStrategy as o}from"./ALoadStrategy.js";import{fetchQueueConcurrency as u}from"./constants.js";import{createQueryAdapter as d}from"./support/queryAdapters.js";import{FeatureSetReaderJSON as c}from"../../support/FeatureSetReaderJSON.js";class l extends o{constructor(e,t,r){super(e.metadata,t,r),this._service=e,this._didApplyOverride=!1,this._queue=new i({concurrency:u,process:async e=>{const t={signal:e.options?.signal,query:e.query.customParameters,useQueue:!0};return this._adapter.executeQuery(e.query.inner,t)}}),this._queryInfo=n.create(e,{...t.full,...t.partial},this.metadata),this._adapter=d(e,this.metadata,r.connection),this._lastEditDate=e.queryMetadata.lastEditDate}destroy(){super.destroy(),this._adapter.destroy()}unsafeSetQueryHistoricMoment(e){this._queryInfo.updateHistoricMoment(e)}async tryUpdate(e,t){if(s(this.availableFields,t.availableFields)){if(this._didApplyOverride||await this._queryLastEditDateChanged())return!1;await this._updateFields(t.availableFields)}return this._schema.partial=t,!0}async queryByObjectId(e,t){if(0===e.length)return c.empty(this.metadata);const r=this._queryInfo.createQuery({objectIds:e});return r.inner.outFields=t,this._fetch(r,null,null)}get availableFields(){return this._schema.partial.availableFields}get definitionExpression(){return this._schema.full.definitionExpression}_onOverride(){this._didApplyOverride=!0}async _updateFields(e){this._queryInfo.updateFields(e);const r=Array.from(this.store.chunks()).map(async e=>{const t=a.fromJSON(e.queryInfo.queryJSON);if(t)try{return await this._tryUpdateFields(e.reader,t,{chunkId:e.chunkId}),null}catch(r){return r}}),s=(await Promise.all(r)).filter(e=>e);if(s.length)throw new t("featurelayer-query","Encountered errors when downloading fields",{errors:s})}async _fetch(e,t,r){const s=await this._enqueue(e,t);return await this._tryUpdateFields(s,e.inner,r),s}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;if(!("source"in this._service))return!1;const t=this._service.source,r={...t.query,f:"json"},s=(await e(t.path,{query:r,responseType:"json"})).data.editingInfo.lastEditDate;return s!==this._lastEditDate&&(this._lastEditDate=s,!0)}async _tryUpdateFields(e,s,i){const a=this._queryInfo.createPatchFieldsQuery(s,e,i);if(!a)return;const n=await this._enqueue(a,this._options);n.getSize()===e.getSize()?e.joinAttributes(n):r.getLogger("esri.views.2d.layers.features.sources.strategies.AFetchLoadStrategy").error(new t("featurelayer-query",`Failed to join features. Expected a count of ${e.getSize()} features, but got ${n.getSize()}`,{query:a.inner.toJSON(),debugInfo:i}))}async _enqueue(e,t){return this._connection.onEvent({type:"fetchStart"}),this._queue.push({query:e,options:t}).finally(()=>{this._connection.onEvent({type:"fetchEnd",done:0===this._queue.length})})}}export{l as AFeatureLoadStrategy};
2
+ import e from"../../../../../../request.js";import t from"../../../../../../core/Error.js";import r from"../../../../../../core/Logger.js";import{notDeepEqual as s}from"../../../../../../core/object.js";import{QueueProcessor as i}from"../../../../../../core/QueueProcessor.js";import a from"../../../../../../rest/support/Query.js";import{FeatureSourceQueryInfo as n}from"../FeatureSourceQueryInfo.js";import{ALoadStrategy as o}from"./ALoadStrategy.js";import{fetchQueueConcurrency as u}from"./constants.js";import{createQueryAdapter as d}from"./support/queryAdapters.js";import{FeatureSetReaderJSON as c}from"../../support/FeatureSetReaderJSON.js";class l extends o{constructor(e,t,r){super(e.metadata,t,r),this._service=e,this._didApplyOverride=!1,this._queue=new i({concurrency:u,process:async e=>{const t={signal:e.options?.signal,query:e.query.customParameters,useQueue:!0};return this._adapter.executeQuery(e.query.inner,t)}}),this._queryInfo=n.create(e,{...t.full,...t.partial},this.metadata),this._adapter=d(e,this.metadata,r.connection),this._lastEditDate=e.queryMetadata.lastEditDate}destroy(){super.destroy(),this._adapter.destroy()}unsafeSetQueryHistoricMoment(e){this._queryInfo.updateHistoricMoment(e)}async tryUpdate(e,t){if(s(this.availableFields,t.availableFields)){if(this._didApplyOverride||await this._queryLastEditDateChanged())return!1;await this._updateFields(t.availableFields)}return this._schema.partial=t,!0}async queryByObjectId(e,t){if(0===e.length)return c.empty(this.metadata);const r=this._queryInfo.createQuery({objectIds:e});return r.inner.outFields=t,this._fetch(r,null,null)}get availableFields(){return this._schema.partial.availableFields}get definitionExpression(){return this._schema.full.definitionExpression}_onOverride(){this._didApplyOverride=!0}async _updateFields(e){this._queryInfo.updateFields(e);const r=Array.from(this.store.chunks()).map(async e=>{const t=a.fromJSON(e.queryInfo.queryJSON);if(t)try{return await this._tryUpdateFields(e.reader,t,{chunkId:e.chunkId}),null}catch(r){return r}}),s=(await Promise.all(r)).filter(e=>null!=e);if(s.length)throw new t("featurelayer-query","Encountered errors when downloading fields",{errors:s});await this._onUpdateFields()}async _fetch(e,t,r){const s=await this._enqueue(e,t);return await this._tryUpdateFields(s,e.inner,r),s}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;if(!("source"in this._service))return!1;const t=this._service.source,r={...t.query,f:"json"},s=(await e(t.path,{query:r,responseType:"json"})).data.editingInfo.lastEditDate;return s!==this._lastEditDate&&(this._lastEditDate=s,!0)}async _onUpdateFields(){}async _tryUpdateFields(e,s,i){const a=this._queryInfo.createPatchFieldsQuery(s,e,i);if(!a)return;const n=await this._enqueue(a,this._options);n.getSize()===e.getSize()?e.joinAttributes(n):r.getLogger("esri.views.2d.layers.features.sources.strategies.AFetchLoadStrategy").error(new t("featurelayer-query",`Failed to join features. Expected a count of ${e.getSize()} features, but got ${n.getSize()}`,{query:a.inner.toJSON(),debugInfo:i}))}async _enqueue(e,t){return this._connection.onEvent({type:"fetchStart"}),this._queue.push({query:e,options:t}).finally(()=>{this._connection.onEvent({type:"fetchEnd",done:0===this._queue.length})})}}export{l as AFeatureLoadStrategy};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{handlesGroup as e}from"../../../../../../core/handleUtils.js";import has from"../../../../../../core/has.js";import{getOrCreateMapValue as t}from"../../../../../../core/MapUtils.js";import{throwIfAborted as r,isAbortError as o,onAbort as s}from"../../../../../../core/promiseUtils.js";import n from"../../../../../../rest/support/QuantizationParameters.js";import{AFeatureTileLoadStrategy as i}from"./AFeatureTileLoadStrategy.js";import{ByReferenceTileSourceChunk as a}from"./chunks/ByReferenceTileSourceChunk.js";import{PagedTileSourceChunk as l}from"./chunks/PagedTileSourceChunk.js";import{FeatureSetReaderJSON as c}from"../../support/FeatureSetReaderJSON.js";import{RefCounted as u}from"../../support/RefCounted.js";class d{constructor(t,r){this.subscription=t,this._pages=new Set,this._controller=new AbortController,this._done=!1,this._handles=e([s(t.signal,()=>this._controller.abort()),s(r,()=>this._controller.abort())])}destroy(){this._controller.abort(),this._handles.remove()}get pageStart(){let e=-1;for(const t of this._pages.values())e=Math.max(e,t);return e+1}get done(){return this._done}get options(){return{signal:this._controller.signal}}add(e,t){this._pages.add(e),this._done=this._done||t}}class h extends i{constructor(){super(...arguments),this._loadStates=new Map,this._levels=new Map}destroy(){super.destroy();for(const e of this._loadStates.values())e.destroy();this._loadStates.clear()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(e){const r=t(this._loadStates,e.key.id,()=>new d(e,this._options));for await(const t of this._fetchPages(r))this._addChunk(t)}unload(e){super.unload(e),this._loadStates.get(e.key.id)?.destroy(),this._loadStates.delete(e.key.id)}_onRemoveTileChunk(e){if(e instanceof a){const t=e.reader.getCursor(),r=e.tile.resolution;for(;t.next();)this._removeReferenceFeature(t.getObjectId(),r)}}async*_fetchPages(e){let t;try{for await(const t of this._concurrentPageStream(e)){r(e.options);for(const e of t)0!==e.size()&&(yield e)}}catch(s){t=s}if(t&&o(t)||(yield new l(c.empty(this.metadata),null,e.subscription.tile,-1,!0)),t)throw t}async*_concurrentPageStream(e){const t=has("featurelayer-query-tile-concurrency"),r=this._pageStreamAll(e),o=[];let s=!1,n=1;for(;!s;){const e=[];for(;!s&&o.length<n;){const t=r.next();if(!t.value){s=!0;break}const n=t.value;n.then(e=>{e.some(e=>e.reader.exceededTransferLimit)||(s=!0)}).catch(e=>{s=!0}).finally(()=>{o.splice(o.indexOf(n),1)}),o.push(n),e.push(n)}for(const t of e)yield t;o.length&&await Promise.race(o),n<t&&(n+=1)}}*_pageStreamAll(e){const t=Math.ceil(has("featurelayer-query-tile-max-features")/this._queryInfo.getPageSize(!0));for(let r=0;r<t;r++)yield this._downloadPage(r,e)}async _downloadPage(e,t){r(t.options);const o=t.subscription.tile,s=this._queryInfo.createPagedTileQuery(o,e);if(!s){const e=c.empty(this.metadata);return[new l(e,null,o,0,!1)]}s.inner.returnExceededLimitGeometries=!1;const n=await this._fetch(s,t.options,{chunkId:`${o.id}-${e}`}),i=[],a=n.getCursor();for(;a.next();){const e=a.getByReferenceVertexCount();e&&(i.push({vertexCount:e,objectId:a.getObjectId()}),a.delete())}const u=new l(n,s.inner.toJSON(),o,e,!1),d=await this._ensureReferenceFeatures(i,o);return r(t.options),[u,...d]}async _ensureReferenceFeatures(e,t){let r=this._levels.get(t.resolution);null==r&&(r=new Map,this._levels.set(t.resolution,r));return(await Promise.all(this._ensureReferenceLevelFeatures(r,e,t.resolution))).map(e=>new a(e,t))}_removeReferenceFeature(e,t){const r=this._levels.get(t);if(null==r)throw new Error("Expected to find reference feature.");this._removeReferenceLevelFeature(r,e)}_ensureReferenceLevelFeatures(e,t,r){const o=[],s=new n({mode:"view",originPosition:"upper-left",tolerance:r});for(const n of t){let t=e.get(n.objectId);null==t&&(t=new u(this._queryFeature(n.objectId,s)),e.set(n.objectId,t)),t.increment(),o.push(t.data)}return o}_removeReferenceLevelFeature(e,t){const r=e.get(t);if(null==r)throw new Error("Expected to find reference feature.");r.decrement(),r.empty&&e.delete(t)}async _queryFeature(e,t){const r=this._queryInfo.createQuery({objectIds:[e]});return r.inner.quantizationParameters=t,this._fetch(r,null,null)}}export{h as FeatureHybridTileLoadStrategy};
2
+ import e from"../../../../../../core/Error.js";import{handlesGroup as t}from"../../../../../../core/handleUtils.js";import has from"../../../../../../core/has.js";import{getOrCreateMapValue as r}from"../../../../../../core/MapUtils.js";import{throwIfAborted as o,isAbortError as s,onAbort as n}from"../../../../../../core/promiseUtils.js";import i from"../../../../../../rest/support/QuantizationParameters.js";import{AFeatureTileLoadStrategy as a}from"./AFeatureTileLoadStrategy.js";import{ByReferenceTileSourceChunk as l}from"./chunks/ByReferenceTileSourceChunk.js";import{PagedTileSourceChunk as c}from"./chunks/PagedTileSourceChunk.js";import{FeatureSetReaderJSON as u}from"../../support/FeatureSetReaderJSON.js";import{RefCounted as d}from"../../support/RefCounted.js";class h{constructor(e,r){this.subscription=e,this._pages=new Set,this._controller=new AbortController,this._done=!1,this._handles=t([n(e.signal,()=>this._controller.abort()),n(r,()=>this._controller.abort())])}destroy(){this._controller.abort(),this._handles.remove()}get pageStart(){let e=-1;for(const t of this._pages.values())e=Math.max(e,t);return e+1}get done(){return this._done}get options(){return{signal:this._controller.signal}}add(e,t){this._pages.add(e),this._done=this._done||t}}class f extends a{constructor(){super(...arguments),this._loadStates=new Map,this._levels=new Map}destroy(){super.destroy();for(const e of this._loadStates.values())e.destroy();this._loadStates.clear()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(e){const t=r(this._loadStates,e.key.id,()=>new h(e,this._options));for await(const r of this._fetchPages(t))this._addChunk(r)}unload(e){super.unload(e),this._loadStates.get(e.key.id)?.destroy(),this._loadStates.delete(e.key.id)}_onRemoveTileChunk(e){if(e instanceof l){const t=e.reader.getCursor(),r=e.tile.resolution;for(;t.next();)this._removeReferenceFeature(t.getObjectId(),r)}}async*_fetchPages(e){let t;try{for await(const t of this._concurrentPageStream(e)){o(e.options);for(const e of t)0!==e.size()&&(yield e)}}catch(r){t=r}if(t&&s(t)||(yield new c(u.empty(this.metadata),null,e.subscription.tile,-1,!0)),t)throw t}async*_concurrentPageStream(e){const t=has("featurelayer-query-tile-concurrency"),r=this._pageStreamAll(e),o=[];let s=!1,n=1;for(;!s;){const e=[];for(;!s&&o.length<n;){const t=r.next();if(!t.value){s=!0;break}const n=t.value;n.then(e=>{e.some(e=>e.reader.exceededTransferLimit)||(s=!0)}).catch(e=>{s=!0}).finally(()=>{o.splice(o.indexOf(n),1)}),o.push(n),e.push(n)}for(const t of e)yield t;o.length&&await Promise.race(o),n<t&&(n+=1)}}*_pageStreamAll(e){const t=Math.ceil(has("featurelayer-query-tile-max-features")/this._queryInfo.getPageSize(!0));for(let r=0;r<t;r++)yield this._downloadPage(r,e)}async _downloadPage(e,t){o(t.options);const r=t.subscription.tile,s=this._queryInfo.createPagedTileQuery(r,e);if(!s){const e=u.empty(this.metadata);return[new c(e,null,r,0,!1)]}s.inner.returnExceededLimitGeometries=!1;const n=await this._fetch(s,t.options,{chunkId:`${r.id}-${e}`}),i=[],a=n.getCursor();for(;a.next();){const e=a.getByReferenceVertexCount();e&&(i.push({vertexCount:e,objectId:a.getObjectId()}),a.delete())}const l=new c(n,s.inner.toJSON(),r,e,!1),d=await this._ensureReferenceFeatures(i,r);return o(t.options),[l,...d]}async _ensureReferenceFeatures(e,t){let r=this._levels.get(t.resolution);null==r&&(r=new Map,this._levels.set(t.resolution,r));return(await Promise.all(this._ensureReferenceLevelFeatures(r,e,t.resolution))).map(e=>new l(e,t))}_removeReferenceFeature(e,t){const r=this._levels.get(t);if(null==r)throw new Error("Expected to find reference feature.");this._removeReferenceLevelFeature(r,e)}_ensureReferenceLevelFeatures(e,t,r){const o=[],s=new i({mode:"view",originPosition:"upper-left",tolerance:r});for(const n of t){let t=e.get(n.objectId);null==t&&(t=new d(this._queryFeature(n.objectId,s)),e.set(n.objectId,t)),t.increment(),o.push(t.data)}return o}async _onUpdateFields(){const t=[];for(const[e,o]of this._levels){const r=new i({mode:"view",originPosition:"upper-left",tolerance:e});for(const[e,s]of o)t.push(this._updateReferenceFields(e,s.data,r))}const r=(await Promise.all(t)).filter(e=>null!=e);if(r.length)throw new e("featurelayer-query","Encountered errors when downloading reference fields",{errors:r})}_removeReferenceLevelFeature(e,t){const r=e.get(t);if(null==r)throw new Error("Expected to find reference feature.");r.decrement(),r.empty&&e.delete(t)}async _updateReferenceFields(e,t,r){try{const s=await t;o(this._options);const n=this._queryInfo.createQuery({objectIds:[e]});return n.inner.quantizationParameters=r,await this._tryUpdateFields(s,n.inner,{chunkId:`reference-${e}`}),null}catch(s){return s}}async _queryFeature(e,t){const r=this._queryInfo.createQuery({objectIds:[e]});return r.inner.quantizationParameters=t,this._fetch(r,null,null)}}export{f as FeatureHybridTileLoadStrategy};
@@ -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/Error.js";import{EventedMixin as r}from"../../core/Evented.js";import{when as n}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{create as s,equals as o,intersection as l}from"../../geometry/support/aaBoundingRect.js";import u from"../GroundView.js";import{ElevationRange as d}from"./support/ElevationRange.js";import{toBoundingRect as p}from"./support/extentUtils.js";import{webMercatorWorldExtent as g,geographicWorldExtent as h}from"./terrain/TerrainConst.js";import{isIntegratedMeshLayerView as c}from"../support/layerViewUtils.js";let v=class extends(r(u)){constructor(){super(...arguments),this._integratedMeshElevationUpdateHandles=new Map}initialize(){super.initialize(),this.addHandles(n(()=>this._terrainSurface,e=>e.on("elevation-change",e=>this._elevationChange(e))));const e=this._integratedMeshElevationUpdateHandles;this.addHandles(this.view.allLayerViews.on("change",t=>{t.added.forEach(t=>{c(t)&&e.set(t,t.elevationProvider.on("elevation-change",e=>this._elevationChange(e)))}),t.removed.forEach(t=>{c(t)&&(e.get(t)?.remove(),e.delete(t))})}))}destroy(){this._integratedMeshElevationUpdateHandles.forEach(e=>e.remove()),this._integratedMeshElevationUpdateHandles.clear()}_elevationChange(e){this.emit("elevation-change",e)}get _integratedMeshGroundLayerView(){const e=this.ground?.integratedMeshGround;if(e)return this.view.basemapView?.groundLayerViews.find(t=>t.layer===e)}get _terrainSurface(){return this.view.basemapTerrain}get _usingTerrain(){return this._terrainSurface?.enabled??!1}get _usingIntegratedMesh(){return this._integratedMeshGroundLayerView?.visible??!1}get spatialReference(){return this._terrainSurface?.spatialReference}get userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(null==t||null==e)return null;const r=s(),n=p(t,r,e)?r:null,i=this._get("userClippingExtent");return o(n,i)?i:n}intersect(e,t,r,n){this._usingTerrain&&this._terrainSurface?.intersect(e,t,r,n);for(const i of this._integratedMeshElevationUpdateHandles.keys())i.intersect(e,t,r,n)}get updating(){return!this.suspended&&((this._source?.updating??!1)||this.layerViews.some(({updating:e})=>e))}getElevation(e,t,r,n){return this._elevationProvider?.getElevation(e,t,r,n)}getElevations(e,t,r){const{_elevationProvider:n}=this;if(n?.getElevations)return n.getElevations(e,t,r);for(let i=0;i<t;++i)r(i,null)}getSphereElevationRange(e,t,r){return this._elevationProvider?.getSphereElevationRange?.(e,t)}getRootElevationRange(){return this._elevationProvider?.getRootElevationRange?.()}get _elevationProvider(){return this._usingIntegratedMesh?this._integratedMeshGroundLayerView?.elevationProvider:this._terrainSurface}get elevationQueryCache(){return this._usingTerrain?this._terrainSurface?.elevationQueryCache:null}get groundExtent(){const{fullGroundExtent:e}=this;return e?this.userClippingExtent?l(e,this.userClippingExtent,s()):this.fullGroundExtent:null}get fullGroundExtent(){if(this._usingTerrain)return this._terrainSurface.fullGroundExtent;if(this._usingIntegratedMesh){const e=this.view.spatialReference;if(e.isWebMercator||e.isWGS84)return f(e);throw new t("GroundView:unsupportedSpatialReference","View spatial reference incompatible with groundLayer")}return null}get visibleElevationRange(){return this._source?.visibleElevationRange??y}get baseOpacity(){return this.ground?.opacity??1}get wireframe(){return!!this._usingTerrain&&(this._terrainSurface?.wireframe??!1)}get suspended(){return this._source?.suspended??!1}get ready(){return this._source?.ready??!1}updateOverlayParameters(){this._terrainSurface?.updateOverlayParameters()}get _source(){return this._usingTerrain?this._terrainSurface:this._usingIntegratedMesh?this._integratedMeshGroundLayerView:null}requestRender(e){this.view.stage.renderView?.requestRender(e)}};e([i({readOnly:!0})],v.prototype,"_integratedMeshGroundLayerView",null),e([i({readOnly:!0})],v.prototype,"_terrainSurface",null),e([i({readOnly:!0})],v.prototype,"_usingTerrain",null),e([i({readOnly:!0})],v.prototype,"_usingIntegratedMesh",null),e([i({readOnly:!0})],v.prototype,"spatialReference",null),e([i({readOnly:!0})],v.prototype,"userClippingExtent",null),e([i({type:Boolean,readOnly:!0})],v.prototype,"updating",null),e([i({readOnly:!0})],v.prototype,"elevationQueryCache",null),e([i({readOnly:!0})],v.prototype,"groundExtent",null),e([i({readOnly:!0})],v.prototype,"fullGroundExtent",null),e([i({readOnly:!0})],v.prototype,"visibleElevationRange",null),e([i({readOnly:!0})],v.prototype,"baseOpacity",null),e([i({readOnly:!0})],v.prototype,"wireframe",null),e([i({readOnly:!0})],v.prototype,"suspended",null),e([i({readOnly:!0})],v.prototype,"ready",null),e([i({readOnly:!0})],v.prototype,"_source",null),v=e([a("esri.views.3d.GroundView3D")],v);const y=new d(0,0);function f(e){return e.isWebMercator?g:h}export{v as GroundView3D};
2
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{EventedMixin as r}from"../../core/Evented.js";import{when as n,watch as i}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{create as o,equals as l,intersection as u}from"../../geometry/support/aaBoundingRect.js";import d from"../GroundView.js";import{ElevationRange as p}from"./support/ElevationRange.js";import{toBoundingRect as g}from"./support/extentUtils.js";import{webMercatorWorldExtent as h,geographicWorldExtent as c}from"./terrain/TerrainConst.js";import{isIntegratedMeshLayerView as y}from"../support/layerViewUtils.js";let v=class extends(r(d)){constructor(){super(...arguments),this._integratedMeshElevationUpdateHandles=new Map}initialize(){super.initialize();const e=()=>{this.emit("elevation-query-change")};this.addHandles(n(()=>this._terrainSurface,e=>e.on("elevation-change",e=>this._elevationChange(e))));const t=this._integratedMeshElevationUpdateHandles;this.addHandles(this.view.allLayerViews.on("change",e=>{e.added.forEach(e=>{y(e)&&t.set(e,e.elevationProvider.on("elevation-change",e=>this._elevationChange(e)))}),e.removed.forEach(e=>{y(e)&&(t.get(e)?.remove(),t.delete(e))})})),this.addHandles([i(()=>this.memoizedElevationQueryDependencies,e)])}destroy(){this._integratedMeshElevationUpdateHandles.forEach(e=>e.remove()),this._integratedMeshElevationUpdateHandles.clear()}get memoizedElevationQueryDependencies(){return(this.ground?.allLayers??[]).filter(e=>"elevation"===e.type||"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain).map(e=>e.memoizedElevationQueryDependencies)}_elevationChange(e){this.emit("elevation-change",e)}get _integratedMeshGroundLayerView(){const e=this.ground?.integratedMeshGround;if(e)return this.view.basemapView?.groundLayerViews.find(t=>t.layer===e)}get _terrainSurface(){return this.view.basemapTerrain}get _usingTerrain(){return this._terrainSurface?.enabled??!1}get _usingIntegratedMesh(){return this._integratedMeshGroundLayerView?.visible??!1}get spatialReference(){return this._terrainSurface?.spatialReference}get userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(null==t||null==e)return null;const r=o(),n=g(t,r,e)?r:null,i=this._get("userClippingExtent");return l(n,i)?i:n}intersect(e,t,r,n){this._usingTerrain&&this._terrainSurface?.intersect(e,t,r,n);for(const i of this._integratedMeshElevationUpdateHandles.keys())i.intersect(e,t,r,n)}get updating(){return!this.suspended&&((this._source?.updating??!1)||this.layerViews.some(({updating:e})=>e))}getElevation(e,t,r,n){return this._elevationProvider?.getElevation(e,t,r,n)}getElevations(e,t,r){const{_elevationProvider:n}=this;if(n?.getElevations)return n.getElevations(e,t,r);for(let i=0;i<t;++i)r(i,null)}getSphereElevationRange(e,t,r){return this._elevationProvider?.getSphereElevationRange?.(e,t)}getRootElevationRange(){return this._elevationProvider?.getRootElevationRange?.()}get _elevationProvider(){return this._usingIntegratedMesh?this._integratedMeshGroundLayerView?.elevationProvider:this._terrainSurface}get elevationQueryCache(){return this._usingTerrain?this._terrainSurface?.elevationQueryCache:null}get elevationQueryReady(){for(const e of this.ground?.allLayers??[])if("integrated-mesh-3dtiles"===e.type&&e.replacesTerrain&&"failed"!==e.loadStatus&&null==e.queryElevationCallback)return!1;return!0}get groundExtent(){const{fullGroundExtent:e}=this;return e?this.userClippingExtent?u(e,this.userClippingExtent,o()):this.fullGroundExtent:null}get fullGroundExtent(){if(this._usingTerrain)return this._terrainSurface.fullGroundExtent;if(this._usingIntegratedMesh){const e=this.view.spatialReference;if(e.isWebMercator||e.isWGS84)return m(e);throw new t("GroundView:unsupportedSpatialReference","View spatial reference incompatible with groundLayer")}return null}get visibleElevationRange(){return this._source?.visibleElevationRange??f}get baseOpacity(){return this.ground?.opacity??1}get wireframe(){return!!this._usingTerrain&&(this._terrainSurface?.wireframe??!1)}get suspended(){return this._source?.suspended??!1}get ready(){return this._source?.ready??!1}updateOverlayParameters(){this._terrainSurface?.updateOverlayParameters()}get _source(){return this._usingTerrain?this._terrainSurface:this._usingIntegratedMesh?this._integratedMeshGroundLayerView:null}requestRender(e){this.view.stage.renderView?.requestRender(e)}};e([a()],v.prototype,"memoizedElevationQueryDependencies",null),e([a({readOnly:!0})],v.prototype,"_integratedMeshGroundLayerView",null),e([a({readOnly:!0})],v.prototype,"_terrainSurface",null),e([a({readOnly:!0})],v.prototype,"_usingTerrain",null),e([a({readOnly:!0})],v.prototype,"_usingIntegratedMesh",null),e([a({readOnly:!0})],v.prototype,"spatialReference",null),e([a({readOnly:!0})],v.prototype,"userClippingExtent",null),e([a({type:Boolean,readOnly:!0})],v.prototype,"updating",null),e([a({readOnly:!0})],v.prototype,"elevationQueryCache",null),e([a()],v.prototype,"elevationQueryReady",null),e([a({readOnly:!0})],v.prototype,"groundExtent",null),e([a({readOnly:!0})],v.prototype,"fullGroundExtent",null),e([a({readOnly:!0})],v.prototype,"visibleElevationRange",null),e([a({readOnly:!0})],v.prototype,"baseOpacity",null),e([a({readOnly:!0})],v.prototype,"wireframe",null),e([a({readOnly:!0})],v.prototype,"suspended",null),e([a({readOnly:!0})],v.prototype,"ready",null),e([a({readOnly:!0})],v.prototype,"_source",null),v=e([s("esri.views.3d.GroundView3D")],v);const f=new p(0,0);function m(e){return e.isWebMercator?h:c}export{v as GroundView3D};