@arcgis/core 4.32.0-next.20241021 → 4.32.0-next.20241023

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 (257) hide show
  1. package/applications/MapViewer/templateUtils.d.ts +4 -0
  2. package/applications/MapViewer/templateUtils.js +5 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/0b7ee57bec7ffac312f2.js +1 -0
  5. package/assets/esri/core/workers/chunks/{1ba1d9c867ec6a492af9.js → 0f3912bca9fe25eea75c.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{842ebde78db9bfcaf07b.js → 1678d1d0ecb9b2af69a8.js} +1 -1
  7. package/assets/esri/core/workers/chunks/1d16ca7791f64dd7c7fb.js +1 -0
  8. package/assets/esri/core/workers/chunks/1d4be734ff961e313257.js +1 -0
  9. package/assets/esri/core/workers/chunks/{b292758308dfac4ba8ee.js → 2d8aa31dc96bbd014036.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{53f648321c5fde26bfe4.js → 319e06888467f9f460ab.js} +1 -1
  11. package/assets/esri/core/workers/chunks/33cae7ece52a77394b05.js +1 -0
  12. package/assets/esri/core/workers/chunks/{210a954f5299fe105e0b.js → 539060ffb7f230fb1bd0.js} +1 -1
  13. package/assets/esri/core/workers/chunks/545441dcc8e915e63ff1.js +1 -0
  14. package/assets/esri/core/workers/chunks/{303f39b9b7bd33109df8.js → 587df97288a83721d251.js} +1 -1
  15. package/assets/esri/core/workers/chunks/5caa02a7a85d05e253b4.js +1 -0
  16. package/assets/esri/core/workers/chunks/5cfecb320e1dcd258b2e.js +1 -0
  17. package/assets/esri/core/workers/chunks/67018ef25736f0722f6e.js +1 -0
  18. package/assets/esri/core/workers/chunks/89f74819ac1b5884c149.js +1 -0
  19. package/assets/esri/core/workers/chunks/92b2d81ef16877341f97.js +1 -0
  20. package/assets/esri/core/workers/chunks/{e6e77cbdeb99d90caad1.js → 97f62fad6d416a666319.js} +1 -1
  21. package/assets/esri/core/workers/chunks/98c1956b2e27058c8a51.js +1 -0
  22. package/assets/esri/core/workers/chunks/9c8a910b6261a4d5da77.js +1 -0
  23. package/assets/esri/core/workers/chunks/ab6eaa3ae2e233f91a5e.js +1 -0
  24. package/assets/esri/core/workers/chunks/{63719f892a7d1025c7d3.js → b42c1ab7579a3c464f72.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{03eba36affe6ed1f5a11.js → bc4ef18d0a02354186e3.js} +7 -7
  26. package/assets/esri/core/workers/chunks/{c71304c88fce556340ef.js → c859f73b57a764e99b02.js} +1 -1
  27. package/assets/esri/core/workers/chunks/cb3038ec3ef0d86bf2a0.js +1 -0
  28. package/assets/esri/core/workers/chunks/{ae20ca2008a2ea6a46b2.js → d8f4bd2b4366388f8a28.js} +1 -1
  29. package/assets/esri/core/workers/chunks/e71fa25ed45bae5a1adb.js +320 -0
  30. package/assets/esri/core/workers/chunks/{9c9a8a529494c6d1dfa3.js → ec9d5af8887854e821c8.js} +1 -1
  31. package/assets/esri/libs/parquet/pkg/arcgis_parquet_bg.wasm +0 -0
  32. package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +14 -0
  33. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +1 -1
  34. package/assets/esri/themes/dark/main.css +1 -1
  35. package/assets/esri/themes/light/main.css +1 -1
  36. package/assets/esri/themes/light/view.css +1 -1
  37. package/chunks/Bufferer-BhkgvSV4.js +5 -0
  38. package/chunks/{Distance2DCalculator-DM4OojiI.js → Distance2DCalculator-BX0Ep7eP.js} +1 -1
  39. package/chunks/{GeodeticDistanceCalculator-DzvUOSaR.js → GeodeticDistanceCalculator-B5uO-Y_z.js} +1 -1
  40. package/chunks/OperatorCrosses.js +5 -0
  41. package/chunks/OperatorCut.js +1 -1
  42. package/chunks/OperatorGeodesicBuffer.js +1 -1
  43. package/chunks/OperatorGeodeticArea.js +1 -1
  44. package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
  45. package/chunks/OperatorGeodeticDistance.js +1 -1
  46. package/chunks/OperatorGeodeticLength.js +1 -1
  47. package/chunks/OperatorIntersects.js +5 -0
  48. package/chunks/OperatorMultiPartToSinglePart.js +1 -1
  49. package/chunks/OperatorOverlaps.js +5 -0
  50. package/chunks/OperatorProximity.js +1 -1
  51. package/chunks/OperatorProximityGeodesic.js +1 -1
  52. package/chunks/OperatorShapePreservingLength.js +1 -1
  53. package/chunks/OperatorTouches.js +5 -0
  54. package/chunks/OperatorWithin.js +5 -0
  55. package/chunks/QuadraticBezier.js +1 -1
  56. package/chunks/SSAOBlur.glsl.js +5 -5
  57. package/chunks/SideCalculator2D-CoWc8Oe3.js +1 -1
  58. package/chunks/Transformation2D.js +1 -1
  59. package/core/MemCache.js +1 -1
  60. package/core/MemCachePool.js +1 -1
  61. package/core/unitUtils.js +1 -1
  62. package/geometry/Mesh.js +1 -1
  63. package/geometry/operators/affineTransformOperator.js +1 -1
  64. package/geometry/operators/alphaShapeOperator.js +1 -1
  65. package/geometry/operators/areaOperator.js +1 -1
  66. package/geometry/operators/autoCompleteOperator.js +1 -1
  67. package/geometry/operators/boundaryOperator.js +1 -1
  68. package/geometry/operators/bufferOperator.js +1 -1
  69. package/geometry/operators/centroidOperator.js +1 -1
  70. package/geometry/operators/clipOperator.js +1 -1
  71. package/geometry/operators/containsOperator.js +1 -1
  72. package/geometry/operators/convexHullOperator.js +1 -1
  73. package/geometry/operators/crossesOperator.js +1 -1
  74. package/geometry/operators/cutOperator.js +1 -1
  75. package/geometry/operators/densifyOperator.js +1 -1
  76. package/geometry/operators/differenceOperator.js +1 -1
  77. package/geometry/operators/disjointOperator.js +1 -1
  78. package/geometry/operators/distanceOperator.js +1 -1
  79. package/geometry/operators/equalsOperator.js +1 -1
  80. package/geometry/operators/extendOperator.js +1 -1
  81. package/geometry/operators/generalizeOperator.js +1 -1
  82. package/geometry/operators/geodesicBufferOperator.js +1 -1
  83. package/geometry/operators/geodesicProximityOperator.js +1 -1
  84. package/geometry/operators/geodeticAreaOperator.js +1 -1
  85. package/geometry/operators/geodeticDensifyOperator.js +1 -1
  86. package/geometry/operators/geodeticDistanceOperator.js +1 -1
  87. package/geometry/operators/geodeticLengthOperator.js +1 -1
  88. package/geometry/operators/graphicBufferOperator.js +1 -1
  89. package/geometry/operators/gx/operatorAlphaShape.js +1 -1
  90. package/geometry/operators/gx/operatorAutoComplete.js +1 -1
  91. package/geometry/operators/gx/operatorBoundary.js +1 -1
  92. package/geometry/operators/gx/operatorBuffer.js +1 -1
  93. package/geometry/operators/gx/operatorConvexHull.js +1 -1
  94. package/geometry/operators/gx/operatorDifference.js +1 -1
  95. package/geometry/operators/gx/operatorGeodesicBuffer.js +1 -1
  96. package/geometry/operators/gx/operatorGeodeticArea.js +1 -1
  97. package/geometry/operators/gx/operatorGeodeticDensify.js +1 -1
  98. package/geometry/operators/gx/operatorGeodeticDistance.js +1 -1
  99. package/geometry/operators/gx/operatorGeodeticLength.js +1 -1
  100. package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
  101. package/geometry/operators/gx/operatorIntegrate.js +1 -1
  102. package/geometry/operators/gx/operatorIntersection.js +1 -1
  103. package/geometry/operators/gx/operatorLabelPoint.js +1 -1
  104. package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
  105. package/geometry/operators/gx/operatorLocateBetween.js +1 -1
  106. package/geometry/operators/gx/operatorOffset.js +1 -1
  107. package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
  108. package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
  109. package/geometry/operators/gx/operatorProject.js +1 -1
  110. package/geometry/operators/gx/operatorProximityGeodesic.js +1 -1
  111. package/geometry/operators/gx/operatorSimplify.js +1 -1
  112. package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
  113. package/geometry/operators/gx/operatorUnion.js +1 -1
  114. package/geometry/operators/integrateOperator.js +1 -1
  115. package/geometry/operators/intersectionOperator.js +1 -1
  116. package/geometry/operators/intersectsOperator.js +1 -1
  117. package/geometry/operators/isNearOperator.js +1 -1
  118. package/geometry/operators/json/containsOperator.js +5 -0
  119. package/geometry/operators/json/crossesOperator.js +5 -0
  120. package/geometry/operators/json/disjointOperator.js +5 -0
  121. package/geometry/operators/json/intersectsOperator.js +5 -0
  122. package/geometry/operators/json/offsetOperator.js +5 -0
  123. package/geometry/operators/json/overlapsOperator.js +5 -0
  124. package/geometry/operators/json/touchesOperator.js +5 -0
  125. package/geometry/operators/json/withinOperator.js +5 -0
  126. package/geometry/operators/labelPointOperator.js +1 -1
  127. package/geometry/operators/lengthOperator.js +1 -1
  128. package/geometry/operators/linesToPolygonsOperator.js +1 -1
  129. package/geometry/operators/locateBetweenOperator.js +1 -1
  130. package/geometry/operators/minimumBoundingCircleOperator.js +1 -1
  131. package/geometry/operators/multiPartToSinglePartOperator.js +1 -1
  132. package/geometry/operators/offsetOperator.js +1 -1
  133. package/geometry/operators/overlapsOperator.js +1 -1
  134. package/geometry/operators/polygonOverlayOperator.js +1 -1
  135. package/geometry/operators/polygonSlicerOperator.js +1 -1
  136. package/geometry/operators/projectOperator.js +1 -1
  137. package/geometry/operators/proximityOperator.js +1 -1
  138. package/geometry/operators/relateOperator.js +1 -1
  139. package/geometry/operators/reshapeOperator.js +1 -1
  140. package/geometry/operators/simplifyOperator.js +1 -1
  141. package/geometry/operators/singlePartToMultiPartOperator.js +1 -1
  142. package/geometry/operators/support/apiConverter.js +5 -0
  143. package/geometry/operators/support/initNoPeFactory.js +5 -0
  144. package/geometry/operators/support/jsonConverter.js +5 -0
  145. package/geometry/operators/support/proximityResult.js +1 -1
  146. package/geometry/operators/symmetricDifferenceOperator.js +1 -1
  147. package/geometry/operators/touchesOperator.js +1 -1
  148. package/geometry/operators/unionOperator.js +1 -1
  149. package/geometry/operators/withinOperator.js +1 -1
  150. package/geometry/support/MeshVertexAttributes.js +1 -1
  151. package/interfaces.d.ts +134 -0
  152. package/layers/LinkChartLayer.js +1 -1
  153. package/layers/SceneLayer.js +1 -1
  154. package/layers/graphics/OptimizedGeometry.js +1 -1
  155. package/layers/graphics/sources/ParquetSource.js +1 -1
  156. package/layers/knowledgeGraph/supportUtils.js +1 -1
  157. package/layers/support/ElevationQueryTileCache.js +1 -1
  158. package/layers/support/ElevationTileData.js +1 -1
  159. package/layers/support/mediaUtils.js +1 -1
  160. package/layers/support/parquetLayerUtils.js +1 -1
  161. package/layers/support/rasterFunctions/ClipFunction.js +1 -1
  162. package/layers/support/rasterFunctions/clipUtils.js +1 -1
  163. package/layers/support/rasterFunctions/localUtils.js +1 -1
  164. package/libs/parquet/parquet.js +1 -1
  165. package/linkChart/LinkChartProperties.js +1 -1
  166. package/package.json +1 -1
  167. package/smartMapping/raster/renderers/classBreaks.js +1 -1
  168. package/smartMapping/raster/renderers/rgb.js +1 -1
  169. package/smartMapping/raster/renderers/stretch.js +1 -1
  170. package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
  171. package/smartMapping/raster/support/adapters/RasterLayerAdapter.js +1 -1
  172. package/smartMapping/renderers/support/rendererUtils.d.ts +4 -0
  173. package/support/revision.js +1 -1
  174. package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
  175. package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
  176. package/views/2d/engine/vectorTiles/TileHandler3D.js +1 -1
  177. package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
  178. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
  179. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerShader.js +1 -1
  180. package/views/2d/grid/GridView2D.js +1 -1
  181. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  182. package/views/2d/layers/MediaLayerView2D.js +1 -1
  183. package/views/2d/layers/TileLayerView2D.js +1 -1
  184. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  185. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  186. package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
  187. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  188. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  189. package/views/3d/glTF/loader.js +1 -1
  190. package/views/3d/layers/I3SMeshView3D.js +1 -1
  191. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  192. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  193. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  194. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  195. package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
  196. package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
  197. package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
  198. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  199. package/views/3d/layers/i3s/CachedMeshData.js +5 -0
  200. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  201. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  202. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  203. package/views/3d/layers/support/FeatureTile.js +1 -1
  204. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  205. package/views/3d/state/ViewStateManager.js +1 -1
  206. package/views/3d/state/controllers/FovController.js +1 -1
  207. package/views/3d/support/buffer/InterleavedLayout.js +1 -1
  208. package/views/3d/terrain/Tile.js +1 -1
  209. package/views/3d/terrain/TileTexture.js +1 -1
  210. package/views/3d/webgl/ManagedFBO.js +1 -1
  211. package/views/3d/webgl/ManagedFBOAttachment.js +1 -1
  212. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  213. package/views/3d/webgl-engine/core/FBOPool.js +1 -1
  214. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +1 -1
  215. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  216. package/views/3d/webgl-engine/materials/ProceduralTextureRepository.js +1 -1
  217. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  218. package/views/3d/webgl-engine/shaders/SSAOBlur.glsl.js +1 -1
  219. package/views/input/BrowserEventSource.js +1 -1
  220. package/views/webgl/Texture.js +1 -1
  221. package/views/webgl/VertexArrayObject.js +1 -1
  222. package/webdoc/support/webdocSaveUtils.js +1 -1
  223. package/widgets/Attribution/AttributionViewModel.js +1 -1
  224. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  225. package/widgets/BatchAttributeForm/css.js +1 -1
  226. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  227. package/widgets/BatchAttributeForm.js +1 -1
  228. package/widgets/ElevationProfile/support/ElevationProfileView2D.js +1 -1
  229. package/widgets/ElevationProfile/support/ProfileLine2D.js +5 -0
  230. package/widgets/ElevationProfile/support/ProfileLines3D.js +1 -1
  231. package/widgets/ElevationProfile/support/constants.js +1 -1
  232. package/widgets/ElevationProfile/support/visualizationUtils.js +5 -0
  233. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  234. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  235. package/widgets/FeatureTable/support/columnUtils.js +1 -1
  236. package/widgets/FeatureTable/support/tableUtils.js +1 -1
  237. package/widgets/FeatureTable/support/templateUtils.js +5 -0
  238. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  239. package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
  240. package/widgets/support/GridControls.js +1 -1
  241. package/assets/esri/core/workers/chunks/03d0394fff1463c224f9.js +0 -1
  242. package/assets/esri/core/workers/chunks/0c40cac18711f79f0a7d.js +0 -1
  243. package/assets/esri/core/workers/chunks/1a97f98facfc62a9fc69.js +0 -1
  244. package/assets/esri/core/workers/chunks/1e3ed3ee48c2977cff6f.js +0 -1
  245. package/assets/esri/core/workers/chunks/1fc064e37d030e449d5e.js +0 -1
  246. package/assets/esri/core/workers/chunks/4daab36de5efa03a8cbb.js +0 -1
  247. package/assets/esri/core/workers/chunks/77d129134c2a66cd86d8.js +0 -1
  248. package/assets/esri/core/workers/chunks/88bd9e023764da377aa7.js +0 -1
  249. package/assets/esri/core/workers/chunks/92ce57cb12d9a7a3699e.js +0 -1
  250. package/assets/esri/core/workers/chunks/a5675c989d00b7400f98.js +0 -1
  251. package/assets/esri/core/workers/chunks/c06c5c815b5e37717fa1.js +0 -1
  252. package/assets/esri/core/workers/chunks/ca1385e165aae8a32ca2.js +0 -1
  253. package/assets/esri/core/workers/chunks/ce8c1208916f54af7e68.js +0 -320
  254. package/assets/esri/core/workers/chunks/df51c93b2dbcc89efc23.js +0 -1
  255. package/assets/esri/core/workers/chunks/efa3c919261672871f2f.js +0 -1
  256. package/chunks/Bufferer-fr1_Nc47.js +0 -5
  257. package/geometry/operators/support/converterAPI.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import r from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{createTask as s,resultOrAbort as o,result as n}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as a,estimateNumberByteSize as d}from"../../../../core/byteSizeEstimations.js";import c from"../../../../core/Collection.js";import{makeHandle as h}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import l from"../../../../core/Logger.js";import{abortMaybe as u,destroyMaybe as m}from"../../../../core/maybe.js";import{whenOrAbort as p,createResolver as g}from"../../../../core/promiseUtils.js";import y from"../../../../core/ReactiveSet.js";import{watch as f,sync as b}from"../../../../core/reactiveUtils.js";import{property as _}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as O}from"../../../../geometry/support/spatialReferenceUtils.js";import{formatNumber as j}from"../../../../intl/number.js";import{getMaximumQuerySize as C,queryAllJSON as I}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as w,extractMesh as A}from"../../../../rest/support/meshFeatureSet.js";import{isTimeoutError as F}from"../../../../support/requestUtils.js";import{ViewingMode as x}from"../../../ViewingMode.js";let G=class extends r{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=E,this._definitionExpressionDirty=!0,this._interactiveEditingSessions=new c,this.geometryOverrides=new c,this._clientGeometryCache=new Map,this._attributeChangedObjectIds=new y,this._geometryChangedObjectIds=new y,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController,this._applyGeometryOverridesTask=null,this._featureIdLocks=new Map}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this.addHandles(f((()=>this.layer.definitionExpression),(async()=>{this._definitionExpressionDirty=!0,this._pendingFetchChangedObjectIds||(this._applyGeometryOverridesTask=u(this._applyGeometryOverridesTask),this._applyGeometryOverridesTask=s((e=>this._queryAndAddGeometryOverrides(e))),await this._applyGeometryOverridesTask.promise)}),b)),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally((()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null}))}destroy(){this._set("layer",null),this._memCache=m(this._memCache),this._pendingFetchAbortController=u(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null,this._featureIdLocks.clear()}get is3DOFL(){return null!=this._associatedLayer?.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get updating(){return!!this.is3DOFL&&!!(this._pendingFetchChangedObjectIds||this._applyGeometryOverridesTask&&!this._applyGeometryOverridesTask.finished)}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);const t=this._interactiveEditingSessions,r=new L(e,(()=>{t.remove(r)}));return t.unshift(r),r}async applyAttributeOverrides(e,t,r,i=[]){if(this._pendingFetchChangedObjectIds&&await p(this._pendingFetchChangedObjectIds,r),null==t)return;const{attributeData:s,loadedAttributes:o}=t;if(null==o||null==s||0===this._attributeChangedObjectIds.size)return;const n=new Set;for(const d of o)n.add(d.index);for(const d of i)n.has(d.index)||(o.push(d),s[d.name]=new Array(e.length));const a=await this._lockFeatureIds(e);try{const t={attributeData:s,loadedAttributes:o},i=this._getOverridesFromCache(e,t,this._attributeChangedObjectIds),{objectIds:n,fieldNames:a}=i;if(0===n.length||0===a.length)return;const d=await this._queryAttributeOverridesFromAssociatedLayer(n,a,r);if(null==d)return;this._processOverridesFromAssociatedLayer(e,d,a,t)}finally{a.remove()}}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const r=this._clientGeometryCache.get(e);if(null!=r&&(this.geometryOverrides.remove(r),this._clientGeometryCache.delete(e)),null!=t){const r={oid:e,mesh:t};this.geometryOverrides.add(r),this._clientGeometryCache.set(e,r)}}updateAttributeValue(e,t,r){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,r)}featureAdded(e){this.is3DOFL&&this._geometryChangedObjectIds.add(e),this._attributeChangedObjectIds.add(e)}_cacheAttributeValue(e,t,r){this._memCache.put(this._getAttributeCacheKey(e,t),r,this._memCacheAttributeValueSize(r))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:r},i){const s=new Set,o=new Array;for(const a of t)o[a.index]=r[a.name];const n=new Set;for(let a=0;a<e.length;a++){const r=e[a];if(i.has(r))for(const e of t){const t=this._attributeFromCache(r,e.index);void 0===t?(s.add(r),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(s),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const r=this._fromInteractiveEditingSession(e,t);if(void 0!==r)return r;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const r of this._interactiveEditingSessions){if(r.objectId!==e)continue;const i=r.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}async _queryAttributeOverridesFromAssociatedLayer(e,t,r){if(0===e.length)return null;this._logWarningIfMaximumObjectsExceeded();const{associatedLayer:i}=this.layer;if(null==i)return null;const s=i.createQuery(),{objectIdField:o}=i,n=[o,...t];s.where=this.layer.definitionExpression||"1=1",s.returnGeometry=!1,s.outFields=n,s.cacheHint=!0;const a=await this._executeBatchQuery(i,e,s,r),d=[];for(const c of a)if(c.ok)for(const e of c.value.features)d.push(e);return d}async _queryGeometryOverridesFromAssociatedLayer(e,t){if(0===e.length||!this.is3DOFL)return null;const r=this.layer.associatedLayer,i=r.infoFor3D,{spatialReference:s}=r,{state:{viewingMode:o},spatialReference:n}=this.view,a=o===x.Global,d=s.isGeographic;if(a&&!d)return l.getLogger(this).warn("unsupported-pcs-edits-in-global-view",this.layer.title,k(s,n,this.view.viewingMode,M.Mode)),null;if(!a&&d)return l.getLogger(this).warn("unsupported-gcs-edits-in-local-view",this.layer.title,k(s,n,this.view.viewingMode,M.Mode)),null;if(!(O(s,n)||a&&n.isWebMercator&&s.isWGS84))return l.getLogger(this).warn("unsupported-mismatched-spatial-reference-edits",this.layer.title,k(s,n,this.view.viewingMode,M.SpatialReference)),null;this._logWarningIfMaximumObjectsExceeded();const{objectIdField:c,globalIdField:h}=r,u=[c,...null!=h?[h]:[]],m=r.createQuery();m.where=this.layer.definitionExpression||"1=1",m.returnGeometry=!0,m.outFields=u,m.cacheHint=!0,m.returnZ=r.hasZ,m.returnM=r.hasM;const p=await this._executeBatchQuery(r,e,m,t),g=[];for(const l of p){if(!l.ok)continue;const e=l.value,{assetMaps:t,features:r,globalIdFieldName:o}=e;if(null==t)continue;const n=w(i,t);for(const a of r){const e=A(a,o,s,i,n),t=a;null!=e?(t.geometry=e,g.push(t)):t.geometry=null}}return g}_logWarningIfMaximumObjectsExceeded(){if(!this._warnMaximumChangedObjectsExceeded)return;this._warnMaximumChangedObjectsExceeded=!1;let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${j(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;e+=t?.loaded?` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:` (${this.layer.parsedUrl.path})`,l.getLogger(this).warn("#queryOverrides()",this.layer.title,`${e}.`)}async _executeBatchQuery(e,t,r,s){if(0===t.length)return[];const n=C(e);t=[...t].sort(((e,t)=>e-t));const a=i(t,n).map((t=>{const i=r.clone();return i.objectIds=t,o(I(e,i,{signal:s}))}));return Promise.all(a)}_processOverridesFromAssociatedLayer(e,t,r,{loadedAttributes:i,attributeData:s}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=r.map((t=>(t in s||(s[t]=new Array(e.length)),s[t]))),d=new Map(i.map((e=>[e.name,e.index]))),c=r.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<r.length;t++){const i=c[t],s=h.get(e),o=l.attributes[r[t]];a[t][s]=o,this._cacheAttributeValue(e,i,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?a(e):d()}async _fetchChangedObjectIds(e){const r=this.layer;await r.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:i}=r;if(null==i||!i.capabilities?.operations?.supportsChangeTracking)return;const s=this._getFetchChangedObjectIdsServerGen();if(null==s)return;const o=i.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${o}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:o,serverGen:s}])};if(a){const e=i.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const c=await n(t(`${i.url}/extractChanges`,{method:"post",query:d,timeout:S,signal:e}));if(!c.ok&&F(c.error)){const e=this.layer.title;l.getLogger(this).warn("extractChanges:timeout",e,`${e} could not obtain edited features that are not cached in the scene service. Display of features may not be up to date with the latest edits. Consider re-caching the scene service.`)}if(c.ok&&1===c.value.data?.edits?.length){const t=c.value.data.edits[0],r=t?.objectIds,i=t?.fieldUpdates,s=r?.adds??[],o=r?.updates??[],n=r?.deletes??[],d=[...s,...o,...n],h=a?[...s,...i??o,...n]:[],l=Math.min(this._maximumNumberOfEditOVerrides,d.length);l<d.length&&(this._warnMaximumChangedObjectsExceeded=!0);const u=d.sort(((e,t)=>e-t));for(let e=0;e<l;++e){const t=u[e];this._attributeChangedObjectIds.add(t)}for(const e of h)this._geometryChangedObjectIds.add(e);for(;this._definitionExpressionDirty;)await this._queryAndAddGeometryOverrides(e)}}async _queryAndAddGeometryOverrides(e){this._definitionExpressionDirty=!1;const t=this.layer,{associatedLayer:r}=t;if(null!=r&&r.capabilities?.operations?.supportsChangeTracking&&this.is3DOFL&&this._geometryChangedObjectIds.size>0){const t=await this._queryGeometryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[r.objectIdField],e.geometry)}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp?.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t?.serverGens?.minServerGen?t.serverGens.minServerGen:null}async _lockFeatureIds(e){const t=this._featureIdLocks;let r=!0;for(;r;){const i=new Array;for(const r of e){const e=t.get(r);e&&i.push(e)}0===i.length?r=!1:await Promise.all(i)}const i=g(),s=i.promise;for(const o of e)t.set(o,s);return h((()=>{for(const r of e)t.delete(r);i.resolve()}))}get test(){}};e([_({constructOnly:!0})],G.prototype,"view",void 0),e([_({constructOnly:!0})],G.prototype,"layer",void 0),e([_({readOnly:!0})],G.prototype,"is3DOFL",null),e([_()],G.prototype,"_interactiveEditingSessions",void 0),e([_({readOnly:!0})],G.prototype,"sortedGeometryChangedObjectIds",null),e([_({readOnly:!0})],G.prototype,"geometryOverrides",void 0),e([_()],G.prototype,"_clientGeometryCache",void 0),e([_()],G.prototype,"_associatedLayer",null),e([_({constructOnly:!0})],G.prototype,"memoryController",void 0),e([_()],G.prototype,"_attributeChangedObjectIds",void 0),e([_()],G.prototype,"_geometryChangedObjectIds",void 0),e([_()],G.prototype,"hasGeometryChanges",null),e([_()],G.prototype,"_pendingFetchChangedObjectIds",void 0),e([_()],G.prototype,"_pendingFetchAbortController",void 0),e([_()],G.prototype,"_applyGeometryOverridesTask",void 0),e([_()],G.prototype,"updating",null),e([_()],G.prototype,"isEmpty",null),G=e([v("esri.views.3d.layers.i3s.I3SOverrides")],G);class L{constructor(e,t){this.objectId=e,this._remove=t,this._updates=new Map,this._isActive=!0}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}remove(){this.isActive&&(this._isActive=!1,this._remove())}get isActive(){return this._isActive}}const S=1e4,E=5e4;var M;function k(e,t,r,i){return`Displaying the edits of a SceneLayer with a${i===M.Mode?e.isGeographic?" geographic ":" projected ":" "}spatial reference (wkid:${e.wkid}) in ${r} viewing mode${i===M.SpatialReference?` with spatial reference (wkid:${t.wkid}) `:" "}is not supported. No geometry edits will be displayed for this layer.\nPlease consider re-caching the scene service or changing the ${i===M.Mode?"viewing mode":"view spatial reference"} to display edits.`}!function(e){e[e.Mode=0]="Mode",e[e.SpatialReference=1]="SpatialReference"}(M||(M={}));export{G as I3SOverrides};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import r from"../../../../core/Accessor.js";import{splitIntoChunks as s}from"../../../../core/arrayUtils.js";import{createTask as i,resultOrAbort as o,result as n}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as a,estimateNumberByteSize as d}from"../../../../core/byteSizeEstimations.js";import c from"../../../../core/Collection.js";import{makeHandle as h}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import l from"../../../../core/Logger.js";import{abortMaybe as u,destroyMaybe as m}from"../../../../core/maybe.js";import{whenOrAbort as p,createResolver as g}from"../../../../core/promiseUtils.js";import y from"../../../../core/ReactiveSet.js";import{watch as f,sync as _}from"../../../../core/reactiveUtils.js";import{property as b}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as O}from"../../../../geometry/support/spatialReferenceUtils.js";import{formatNumber as j}from"../../../../intl/number.js";import{getMaximumQuerySize as C,queryAllJSON as w}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as I,extractMesh as F}from"../../../../rest/support/meshFeatureSet.js";import{isTimeoutError as A}from"../../../../support/requestUtils.js";import{ViewingMode as x}from"../../../ViewingMode.js";let G=class extends r{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=k,this._definitionExpressionDirty=!0,this._interactiveEditingSessions=new c,this.geometryOverrides=new c,this._clientGeometryCache=new Map,this._attributeChangedObjectIds=new y,this._geometryChangedObjectIds=new y,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController,this._applyGeometryOverridesTask=null,this._featureIdLocks=new Map}initialize(){this._memCache=new S(this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`)),this.addHandles(f((()=>this.layer.definitionExpression),(async()=>{this._definitionExpressionDirty=!0,this._pendingFetchChangedObjectIds||(this._applyGeometryOverridesTask=u(this._applyGeometryOverridesTask),this._applyGeometryOverridesTask=i((e=>this._queryAndAddGeometryOverrides(e))),await this._applyGeometryOverridesTask.promise)}),_)),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally((()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null}))}destroy(){this._set("layer",null),this._memCache=m(this._memCache),this._pendingFetchAbortController=u(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null,this._featureIdLocks.clear()}get is3DOFL(){return null!=this._associatedLayer?.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get updating(){return!!this.is3DOFL&&!!(this._pendingFetchChangedObjectIds||this._applyGeometryOverridesTask&&!this._applyGeometryOverridesTask.finished)}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);const t=this._interactiveEditingSessions,r=new L(e,(()=>{t.remove(r)}));return t.unshift(r),r}async applyAttributeOverrides(e,t,r,s=[]){if(this._pendingFetchChangedObjectIds&&await p(this._pendingFetchChangedObjectIds,r),null==t)return;const{attributeData:i,loadedAttributes:o}=t;if(null==o||null==i||0===this._attributeChangedObjectIds.size)return;const n=new Set;for(const d of o)n.add(d.index);for(const d of s)n.has(d.index)||(o.push(d),i[d.name]=new Array(e.length));const a=await this._lockFeatureIds(e);try{const t={attributeData:i,loadedAttributes:o},s=this._getOverridesFromCache(e,t,this._attributeChangedObjectIds),{objectIds:n,fieldNames:a}=s;if(0===n.length||0===a.length)return;const d=await this._queryAttributeOverridesFromAssociatedLayer(n,a,r);if(null==d)return;this._processOverridesFromAssociatedLayer(e,d,a,t)}finally{a.remove()}}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const r=this._clientGeometryCache.get(e);if(null!=r&&(this.geometryOverrides.remove(r),this._clientGeometryCache.delete(e)),null!=t){const r={oid:e,mesh:t};this.geometryOverrides.add(r),this._clientGeometryCache.set(e,r)}}updateAttributeValue(e,t,r){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,r)}featureAdded(e){this.is3DOFL&&this._geometryChangedObjectIds.add(e),this._attributeChangedObjectIds.add(e)}_cacheAttributeValue(e,t,r){this._memCache.put(e,t,r)}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:r},s){const i=new Array;for(const a of t)i[a.index]=r[a.name];const o=new Set,n=new Set;for(let a=0;a<e.length;a++){const r=e[a];if(s.has(r))for(const e of t){const t=this._attributeFromCache(r,e.index);void 0===t?(o.add(r),n.add(e.name)):i[e.index][a]=t}}return{objectIds:Array.from(o),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const r=this._fromInteractiveEditingSession(e,t);return void 0!==r?r:this._memCache.get(e,t)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const r of this._interactiveEditingSessions){if(r.objectId!==e)continue;const s=r.getAttribute(t);if(void 0!==s)return s}}async _queryAttributeOverridesFromAssociatedLayer(e,t,r){if(0===e.length)return null;this._logWarningIfMaximumObjectsExceeded();const{associatedLayer:s}=this.layer;if(null==s)return null;const i=s.createQuery(),{objectIdField:o}=s,n=[o,...t];i.where=this.layer.definitionExpression||"1=1",i.returnGeometry=!1,i.outFields=n,i.cacheHint=!0;const a=await this._executeBatchQuery(s,e,i,r),d=[];for(const c of a)if(c.ok)for(const e of c.value.features)d.push(e);return d}async _queryGeometryOverridesFromAssociatedLayer(e,t){if(0===e.length||!this.is3DOFL)return null;const r=this.layer.associatedLayer,s=r.infoFor3D,{spatialReference:i}=r,{state:{viewingMode:o},spatialReference:n}=this.view,a=o===x.Global,d=i.isGeographic;if(a&&!d)return l.getLogger(this).warn("unsupported-pcs-edits-in-global-view",this.layer.title,$(i,n,this.view.viewingMode,D.Mode)),null;if(!a&&d)return l.getLogger(this).warn("unsupported-gcs-edits-in-local-view",this.layer.title,$(i,n,this.view.viewingMode,D.Mode)),null;if(!(O(i,n)||a&&n.isWebMercator&&i.isWGS84))return l.getLogger(this).warn("unsupported-mismatched-spatial-reference-edits",this.layer.title,$(i,n,this.view.viewingMode,D.SpatialReference)),null;this._logWarningIfMaximumObjectsExceeded();const{objectIdField:c,globalIdField:h}=r,u=[c,...null!=h?[h]:[]],m=r.createQuery();m.where=this.layer.definitionExpression||"1=1",m.returnGeometry=!0,m.outFields=u,m.cacheHint=!0,m.returnZ=r.hasZ,m.returnM=r.hasM;const p=await this._executeBatchQuery(r,e,m,t),g=[];for(const l of p){if(!l.ok)continue;const e=l.value,{assetMaps:t,features:r,globalIdFieldName:o}=e;if(null==t)continue;const n=I(s,t);for(const a of r){const e=F(a,o,i,s,n),t=a;null!=e?(t.geometry=e,g.push(t)):t.geometry=null}}return g}_logWarningIfMaximumObjectsExceeded(){if(!this._warnMaximumChangedObjectsExceeded)return;this._warnMaximumChangedObjectsExceeded=!1;let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${j(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;e+=t?.loaded?` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:` (${this.layer.parsedUrl.path})`,l.getLogger(this).warn("#queryOverrides()",this.layer.title,`${e}.`)}async _executeBatchQuery(e,t,r,i){if(0===t.length)return[];const n=C(e);t=[...t].sort(((e,t)=>e-t));const a=s(t,n).map((t=>{const s=r.clone();return s.objectIds=t,o(w(e,s,{signal:i}))}));return Promise.all(a)}_processOverridesFromAssociatedLayer(e,t,r,{loadedAttributes:s,attributeData:i}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=r.map((t=>(t in i||(i[t]=new Array(e.length)),i[t]))),d=new Map(s.map((e=>[e.name,e.index]))),c=r.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<r.length;t++){const s=c[t],i=h.get(e),o=l.attributes[r[t]];a[t][i]=o,this._cacheAttributeValue(e,s,o)}}}async _fetchChangedObjectIds(e){const r=this.layer;await r.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:s}=r;if(null==s||!s.capabilities?.operations?.supportsChangeTracking)return;const i=this._getFetchChangedObjectIdsServerGen();if(null==i)return;const o=s.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${o}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:o,serverGen:i}])};if(a){const e=s.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const c=await n(t(`${s.url}/extractChanges`,{method:"post",query:d,timeout:E,signal:e}));if(!c.ok&&A(c.error)){const e=this.layer.title;l.getLogger(this).warn("extractChanges:timeout",e,`${e} could not obtain edited features that are not cached in the scene service. Display of features may not be up to date with the latest edits. Consider re-caching the scene service.`)}if(c.ok&&1===c.value.data?.edits?.length){const t=c.value.data.edits[0],r=t?.objectIds,s=t?.fieldUpdates,i=r?.adds??[],o=r?.updates??[],n=r?.deletes??[],d=[...i,...o,...n],h=a?[...i,...s??o,...n]:[],l=Math.min(this._maximumNumberOfEditOVerrides,d.length);l<d.length&&(this._warnMaximumChangedObjectsExceeded=!0);const u=d.sort(((e,t)=>e-t));for(let e=0;e<l;++e){const t=u[e];this._attributeChangedObjectIds.add(t)}for(const e of h)this._geometryChangedObjectIds.add(e);for(;this._definitionExpressionDirty;)await this._queryAndAddGeometryOverrides(e)}}async _queryAndAddGeometryOverrides(e){this._definitionExpressionDirty=!1;const t=this.layer,{associatedLayer:r}=t;if(null!=r&&r.capabilities?.operations?.supportsChangeTracking&&this.is3DOFL&&this._geometryChangedObjectIds.size>0){const t=await this._queryGeometryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[r.objectIdField],e.geometry)}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp?.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t?.serverGens?.minServerGen?t.serverGens.minServerGen:null}async _lockFeatureIds(e){const t=this._featureIdLocks;let r=!0;for(;r;){const s=new Array;for(const r of e){const e=t.get(r);e&&s.push(e)}0===s.length?r=!1:await Promise.all(s)}const s=g(),i=s.promise;for(const o of e)t.set(o,i);return h((()=>{for(const r of e)t.delete(r);s.resolve()}))}get test(){}};e([b({constructOnly:!0})],G.prototype,"view",void 0),e([b({constructOnly:!0})],G.prototype,"layer",void 0),e([b({readOnly:!0})],G.prototype,"is3DOFL",null),e([b()],G.prototype,"_interactiveEditingSessions",void 0),e([b({readOnly:!0})],G.prototype,"sortedGeometryChangedObjectIds",null),e([b({readOnly:!0})],G.prototype,"geometryOverrides",void 0),e([b()],G.prototype,"_clientGeometryCache",void 0),e([b()],G.prototype,"_associatedLayer",null),e([b({constructOnly:!0})],G.prototype,"memoryController",void 0),e([b()],G.prototype,"_attributeChangedObjectIds",void 0),e([b()],G.prototype,"_geometryChangedObjectIds",void 0),e([b()],G.prototype,"hasGeometryChanges",null),e([b()],G.prototype,"_pendingFetchChangedObjectIds",void 0),e([b()],G.prototype,"_pendingFetchAbortController",void 0),e([b()],G.prototype,"_applyGeometryOverridesTask",void 0),e([b()],G.prototype,"updating",null),e([b()],G.prototype,"isEmpty",null),G=e([v("esri.views.3d.layers.i3s.I3SOverrides")],G);class L{constructor(e,t){this.objectId=e,this._remove=t,this._updates=new Map,this._isActive=!0}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}remove(){this.isActive&&(this._isActive=!1,this._remove())}get isActive(){return this._isActive}}class S{constructor(e){this._cache=e}destroy(){this._cache.destroy()}put(e,t,r){this._cache.put(this._getKey(e,t),new M(r))}get(e,t){return this._cache.get(this._getKey(e,t))?.value}_getKey(e,t){return`${e}-${t}`}}class M{constructor(e){this.value=e,this.cachedMemory="string"==typeof e?a(e):d()}}const E=1e4,k=5e4;var D;function $(e,t,r,s){return`Displaying the edits of a SceneLayer with a${s===D.Mode?e.isGeographic?" geographic ":" projected ":" "}spatial reference (wkid:${e.wkid}) in ${r} viewing mode${s===D.SpatialReference?` with spatial reference (wkid:${t.wkid}) `:" "}is not supported. No geometry edits will be displayed for this layer.\nPlease consider re-caching the scene service or changing the ${s===D.Mode?"viewing mode":"view spatial reference"} to display edits.`}!function(e){e[e.Mode=0]="Mode",e[e.SpatialReference=1]="SpatialReference"}(D||(D={}));export{G as I3SOverrides};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import s from"../../../../core/PooledArray.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{d as n,l as o,h as a,v as l,f as h,k as c}from"../../../../chunks/vec32.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as u}from"../../../../chunks/vec42.js";import{create as m,offset as p,contains as g,containsPoint as _,set as f,positiveInfinity as P,equals as b}from"../../../../geometry/support/aaBoundingBox.js";import{create as x}from"../../../../geometry/support/plane.js";import{fromPoints as S}from"../../../../geometry/support/ray.js";import{PclTarget as R}from"./Intersector.js";import{PointHighlights as w}from"./PointHighlights.js";import{isDepth as z,ShaderOutput as A}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as j}from"../../webgl-engine/effects/RenderPlugin.js";import{Default3D as y}from"../../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{newIntersectorResult as I}from"../../webgl-engine/lib/Intersector.js";import{IntersectorType as q,StoreResults as E}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{RenderSlot as O}from"../../webgl-engine/lib/RenderSlot.js";import{VertexArrayObject as v}from"../../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as L}from"../../webgl-engine/lib/VertexAttribute.js";import{P as T,a as N,g as F}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as H}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as M}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{BufferObject as U}from"../../../webgl/BufferObject.js";import{DataType as B,PrimitiveType as C,Usage as W}from"../../../webgl/enums.js";import{VertexElementDescriptor as D}from"../../../webgl/VertexElementDescriptor.js";const G=new Map([["positions",[new D(L.POSITION,3,B.FLOAT,0,12)]],["colors",[new D(L.COLOR,3,B.UNSIGNED_BYTE,0,3,!0)]]]);let V=class extends j{constructor(e){super(e),this.type=q.PCL,this.isGround=!1,this._passParameters=new T,this._highlights=new w({forEachNode:e=>this.forEachNode(e),addHighlight:(e,t,s)=>this._addHighlight(e,t,s),removeHighlight:(e,t)=>this._removeHighlight(e,t)}),this.produces=new Map([[O.OPAQUE_MATERIAL,e=>!(z(e)||e===A.Highlight&&this._highlights.empty)],[O.OPAQUE_MATERIAL_WITHOUT_NORMALS,e=>z(e)]]),this.layerUid="",this._slicePlaneEnabled=!1,this._configuration=new M,this._nodes=new s}initializeRenderContext(e){this._context=e,e.requestRender()}uninitializeRenderContext(){}intersect(e,t,s,i){const r=d(),f=d(),P=d(),b=d(),w=x(),z=e.camera.perScreenPixelRatio/2,A=e.camera.near;n(f,i,s);const j=1/o(f);a(f,f,j),l(P,f),u(w,f[0],f[1],f[2],-h(f,s));const y=new Z,q=new Z,O=new Array,v=m(),L=m(this._passParameters.clipBox);p(L,-s[0],-s[1],-s[2],L),this._nodes.forAll((o=>{const a=o.splatSize*this._passParameters.scaleFactor;let l=o.obb.minimumDistancePlane(w),d=o.obb.maximumDistancePlane(w);l-=J(a,l+A,this._passParameters,z,o.isLeaf),d-=J(a,d+A,this._passParameters,z,o.isLeaf);const u=d<0,m=null!=y.dist&&null!=q.dist&&y.dist<l*j&&q.dist>d*j;if(u||m)return;const x=Y(a,d+A,this._passParameters,z,o.isLeaf);if(!o.obb.intersectRay(s,f,x))return;const S=x*x;o.obb.toAaBoundingBox(v),p(v,-s[0],-s[1],-s[2],v);const R=!g(L,v);n(b,o.origin,s);const I=o.coordinates.length/3;for(let n=0;n<I;n++){if(r[0]=b[0]+o.coordinates[3*n],r[1]=b[1]+o.coordinates[3*n+1],r[2]=b[2]+o.coordinates[3*n+2],R&&!_(L,r))continue;const l=h(r,f),d=c(r)-l*l;if(d>S)continue;let u=l+A;const m=J(a,u,this._passParameters,z,o.isLeaf);if(l-m<0)continue;u-=m;const p=Y(a,u,this._passParameters,z,o.isLeaf);if(d>p*p)continue;const g=(l-m)*j,x=e=>(e.point=K(o,n,e.point),e.dist=g,e.normal=P,e.node=o,e.pointId=n,e.layerUid=this.layerUid,e);if((null==y.dist||g<y.dist)&&(null==t||t(s,i,g))&&x(y),e.options.store!==E.MIN&&(null==q.dist||g>q.dist)&&(null==t||t(s,i,g))&&x(q),e.options.store===E.ALL&&(null==t||t(s,i,g))){const e=new Z;O.push(x(e))}}}));const T=e=>{const{layerUid:t,node:s,pointId:i}=e;return new R(e.point,t,i,(()=>this.createGraphic(s,i,e.point)))},N=(e,t)=>{const s=T(t);e.set(this.type,s,t.dist,t.normal)};if($(y)){const t=e.results.min;(null==t.dist||y.dist<t.dist)&&N(t,y)}if($(q)&&e.options.store!==E.MIN){const t=e.results.max;(null==t.dist||q.dist>t.dist)&&N(t,q)}if(e.options.store===E.ALL){const t=S(s,i);for(const s of O){const i=I(t);N(i,s),e.results.all.push(i)}}}acquireTechniques(e){return 0!==this._nodes.length&&(e.output===A.Color||z(e.output)&&e.bind.slot===O.OPAQUE_MATERIAL_WITHOUT_NORMALS||e.output===A.Highlight)?(this._nodes.forAll((t=>this._initNode(e,t))),this._configuration.drawScreenSize=this._passParameters.drawScreenSpace,this._configuration.useFixedSizes=this._passParameters.useFixedSizes,this._configuration.hasSlicePlane=this._slicePlaneEnabled,this._configuration.hasOccludees=e.bind.hasOccludees,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.output=e.output,this._context.techniques.acquire(H,this._configuration)):null}render(e,t){const{rctx:s,bind:i,output:r}=e,n=s.bindTechnique(t,i,this._passParameters),o=r===A.Highlight;this._nodes.forAll((t=>{0!==t.coordinates.length&&(!o||t.highlights&&t.highlights.some((e=>i.highlight?.name===e.id.highlightGroupName)))&&(n.bindDraw(i,this._passParameters,t),s.bindVAO(t.vao),o?this._renderHighlightFragments(e,t):s.drawArrays(C.POINTS,0,t.coordinates.length/3))}))}_renderHighlightFragments(e,t){const{highlights:s}=t;if(null==s)return;const{rctx:i,bind:r}=e,n=r.highlight?.name;let o=0,a=s[0].componentIndex,l=a+1;const h=()=>{for(;o<s.length&&s[o].id.highlightGroupName!==n;)a=s[o].componentIndex,++o;l=a+1};h();const c=(e,t)=>{const s=t-e;s>0&&i.drawArrays(C.POINTS,e,s)};for(;o<s.length;){const e=s[o];if(e.id.highlightGroupName!==n){c(a,l),++o,h();continue}const t=e.componentIndex;t!==l&&(c(a,l),a=t),l=t+1,++o}c(a,l)}set useFixedSizes(e){this._passParameters.useFixedSizes!==e&&(this._passParameters.useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._passParameters.useFixedSizes}set scaleFactor(e){this._passParameters.scaleFactor!==e&&(this._passParameters.scaleFactor=e,this._requestRender())}get scaleFactor(){return this._passParameters.scaleFactor}set minSizePx(e){this._passParameters.minSizePx!==e&&(this._passParameters.minSizePx=e,this._requestRender())}get minSizePx(){return this._passParameters.minSizePx}set useRealWorldSymbolSizes(e){this._passParameters.useRealWorldSymbolSizes!==e&&(this._passParameters.useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._passParameters.useRealWorldSymbolSizes}set size(e){this._passParameters.size!==e&&(this._passParameters.size=e,this._requestRender())}get size(){return this._passParameters.size}set sizePx(e){this._passParameters.sizePx!==e&&(this._passParameters.sizePx=e,this._requestRender())}get sizePx(){return this._passParameters.sizePx}set clippingBox(e){f(this._passParameters.clipBox,e||P)}get _clippingEnabled(){return!b(this._passParameters.clipBox,P,((e,t)=>e===t))}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let s=null;return this._nodes.filterInPlace((i=>i.id!==e||(s=i,i.vao=t(i.vao),this._highlights.nodeRemoved(i),!1))),this._requestRender(),s}forEachNode(e){this._nodes.forAll(e)}removeAll(){this._nodes.forAll((e=>e.vao=t(e.vao))),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e,t){return this._highlights.add(e,t)}_addHighlight(e,t,s){e.addHighlight(t,s),this._requestRender()}_removeHighlight(e,t){e.removeHighlight(t),this._requestRender()}_initNode(e,t){t.vao??=new v(e.rctx,y,G,new Map([["positions",U.createVertex(e.rctx,W.STATIC_DRAW,t.coordinates)],["colors",U.createVertex(e.rctx,W.STATIC_DRAW,t.rgb)]]))}_requestRender(){this._context&&this._context.requestRender()}};e([i({constructOnly:!0})],V.prototype,"createGraphic",void 0),V=e([r("esri.views.3d.layers.i3s.PointRenderer")],V);class k extends N{constructor(e,t,s,i,r,n,o,a,l=null){super(s,r,t),this.id=e,this.obb=i,this.coordinates=n,this.rgb=o,this.attributes=a,this.pointIdFilterMap=l,this.highlights=null}addHighlight(e,t){let{highlights:s}=this;null==s&&(s=[],this.highlights=s);const i=new ee(e,t);s.push(i);const r=X(i);for(let n=s.length-1;n>0&&r<X(s[n-1]);--n)[s[n-1],s[n]]=[s[n],s[n-1]]}removeHighlight(e){const{highlights:t}=this;if(null==t)return;const s=t.filter((t=>t.id!==e));0===s.length&&(this.highlights=null),this.highlights=s}}function Q(e){return e.hasOwnProperty("splatSize")}function Y(e,t,s,i,r){if(s.drawScreenSpace)return s.fixedSize*t*i;const n=F(r)*t*i;return s.useFixedSizes?Math.min(s.fixedSize/2,n):s.screenMinSize>0?Math.min(Math.max(s.screenMinSize*t*i,e/2),n):Math.min(e/2,n)}function J(e,t,s,i,r){return s.drawScreenSpace?0:Y(e,t,s,i,r)}function K(e,t,s){return null==s&&(s=d()),s[0]=e.origin[0]+e.coordinates[3*t],s[1]=e.origin[1]+e.coordinates[3*t+1],s[2]=e.origin[2]+e.coordinates[3*t+2],s}function X(e){return null!=e.componentIndex?e.componentIndex:-1}class Z{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerUid=""}}function $(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}class ee{constructor(e,t){this.componentIndex=e,this.id=t}}export{V as PointRenderer,k as PointRendererNode,Q as isPointRendererNode};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import s from"../../../../core/PooledArray.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{d as n,l as o,h as a,v as h,f as l,k as c}from"../../../../chunks/vec32.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as u}from"../../../../chunks/vec42.js";import{create as m,offset as g,contains as p,containsPoint as _,set as f,positiveInfinity as P,equals as b}from"../../../../geometry/support/aaBoundingBox.js";import{create as x}from"../../../../geometry/support/plane.js";import{fromPoints as S}from"../../../../geometry/support/ray.js";import{PclTarget as R}from"./Intersector.js";import{PointHighlights as w}from"./PointHighlights.js";import{isDepth as z,ShaderOutput as A}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as j}from"../../webgl-engine/effects/RenderPlugin.js";import{Default3D as y}from"../../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{newIntersectorResult as I}from"../../webgl-engine/lib/Intersector.js";import{IntersectorType as q,StoreResults as E}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{RenderSlot as O}from"../../webgl-engine/lib/RenderSlot.js";import{VertexArrayObject as v}from"../../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as L}from"../../webgl-engine/lib/VertexAttribute.js";import{P as T,a as N,g as F}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as H}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as M}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{BufferObject as U}from"../../../webgl/BufferObject.js";import{DataType as B,PrimitiveType as C,Usage as W}from"../../../webgl/enums.js";import{VertexElementDescriptor as D}from"../../../webgl/VertexElementDescriptor.js";const G=new Map([["positions",[new D(L.POSITION,3,B.FLOAT,0,12)]],["colors",[new D(L.COLOR,3,B.UNSIGNED_BYTE,0,3,!0)]]]);let V=class extends j{constructor(e){super(e),this.type=q.PCL,this.isGround=!1,this._passParameters=new T,this._highlights=new w({forEachNode:e=>this.forEachNode(e),addHighlight:(e,t,s)=>this._addHighlight(e,t,s),removeHighlight:(e,t)=>this._removeHighlight(e,t)}),this.produces=new Map([[O.OPAQUE_MATERIAL,e=>!(z(e)||e===A.Highlight&&this._highlights.empty)],[O.OPAQUE_MATERIAL_WITHOUT_NORMALS,e=>z(e)]]),this.layerUid="",this._slicePlaneEnabled=!1,this._configuration=new M,this._nodes=new s}initializeRenderContext(e){this._context=e,e.requestRender()}uninitializeRenderContext(){}intersect(e,t,s,i){const r=d(),f=d(),P=d(),b=d(),w=x(),z=e.camera.perScreenPixelRatio/2,A=e.camera.near;n(f,i,s);const j=1/o(f);a(f,f,j),h(P,f),u(w,f[0],f[1],f[2],-l(f,s));const y=new Z,q=new Z,O=new Array,v=m(),L=m(this._passParameters.clipBox);g(L,-s[0],-s[1],-s[2],L),this._nodes.forAll((o=>{const a=o.splatSize*this._passParameters.scaleFactor;let h=o.obb.minimumDistancePlane(w),d=o.obb.maximumDistancePlane(w);h-=J(a,h+A,this._passParameters,z,o.isLeaf),d-=J(a,d+A,this._passParameters,z,o.isLeaf);const u=d<0,m=null!=y.dist&&null!=q.dist&&y.dist<h*j&&q.dist>d*j;if(u||m)return;const x=Y(a,d+A,this._passParameters,z,o.isLeaf);if(!o.obb.intersectRay(s,f,x))return;const S=x*x;o.obb.toAaBoundingBox(v),g(v,-s[0],-s[1],-s[2],v);const R=!p(L,v);n(b,o.origin,s);const I=o.coordinates.length/3;for(let n=0;n<I;n++){if(r[0]=b[0]+o.coordinates[3*n],r[1]=b[1]+o.coordinates[3*n+1],r[2]=b[2]+o.coordinates[3*n+2],R&&!_(L,r))continue;const h=l(r,f),d=c(r)-h*h;if(d>S)continue;let u=h+A;const m=J(a,u,this._passParameters,z,o.isLeaf);if(h-m<0)continue;u-=m;const g=Y(a,u,this._passParameters,z,o.isLeaf);if(d>g*g)continue;const p=(h-m)*j,x=e=>(e.point=K(o,n,e.point),e.dist=p,e.normal=P,e.node=o,e.pointId=n,e.layerUid=this.layerUid,e);if((null==y.dist||p<y.dist)&&(null==t||t(s,i,p))&&x(y),e.options.store!==E.MIN&&(null==q.dist||p>q.dist)&&(null==t||t(s,i,p))&&x(q),e.options.store===E.ALL&&(null==t||t(s,i,p))){const e=new Z;O.push(x(e))}}}));const T=e=>{const{layerUid:t,node:s,pointId:i}=e;return new R(e.point,t,i,(()=>this.createGraphic(s,i,e.point)))},N=(e,t)=>{const s=T(t);e.set(this.type,s,t.dist,t.normal)};if($(y)){const t=e.results.min;(null==t.dist||y.dist<t.dist)&&N(t,y)}if($(q)&&e.options.store!==E.MIN){const t=e.results.max;(null==t.dist||q.dist>t.dist)&&N(t,q)}if(e.options.store===E.ALL){const t=S(s,i);for(const s of O){const i=I(t);N(i,s),e.results.all.push(i)}}}acquireTechniques(e){return 0!==this._nodes.length&&(e.output===A.Color||z(e.output)&&e.bind.slot===O.OPAQUE_MATERIAL_WITHOUT_NORMALS||e.output===A.Highlight)?(this._nodes.forAll((t=>this._initNode(e,t))),this._configuration.drawScreenSize=this._passParameters.drawScreenSpace,this._configuration.useFixedSizes=this._passParameters.useFixedSizes,this._configuration.hasSlicePlane=this._slicePlaneEnabled,this._configuration.hasOccludees=e.bind.hasOccludees,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.output=e.output,this._context.techniques.acquire(H,this._configuration)):null}render(e,t){const{rctx:s,bind:i,output:r}=e,n=s.bindTechnique(t,i,this._passParameters),o=r===A.Highlight;this._nodes.forAll((t=>{0!==t.coordinates.length&&(!o||t.highlights&&t.highlights.some((e=>i.highlight?.name===e.id.highlightGroupName)))&&(n.bindDraw(i,this._passParameters,t),s.bindVAO(t.vao),o?this._renderHighlightFragments(e,t):s.drawArrays(C.POINTS,0,t.coordinates.length/3))}))}_renderHighlightFragments(e,t){const{highlights:s}=t;if(null==s)return;const{rctx:i,bind:r}=e,n=r.highlight?.name;let o=0,a=s[0].componentIndex,h=a+1;const l=()=>{for(;o<s.length&&s[o].id.highlightGroupName!==n;)a=s[o].componentIndex,++o;h=a+1};l();const c=(e,t)=>{const s=t-e;s>0&&i.drawArrays(C.POINTS,e,s)};for(;o<s.length;){const e=s[o];if(e.id.highlightGroupName!==n){c(a,h),++o,l();continue}const t=e.componentIndex;t!==h&&(c(a,h),a=t),h=t+1,++o}c(a,h)}set useFixedSizes(e){this._passParameters.useFixedSizes!==e&&(this._passParameters.useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._passParameters.useFixedSizes}set scaleFactor(e){this._passParameters.scaleFactor!==e&&(this._passParameters.scaleFactor=e,this._requestRender())}get scaleFactor(){return this._passParameters.scaleFactor}set minSizePx(e){this._passParameters.minSizePx!==e&&(this._passParameters.minSizePx=e,this._requestRender())}get minSizePx(){return this._passParameters.minSizePx}set useRealWorldSymbolSizes(e){this._passParameters.useRealWorldSymbolSizes!==e&&(this._passParameters.useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._passParameters.useRealWorldSymbolSizes}set size(e){this._passParameters.size!==e&&(this._passParameters.size=e,this._requestRender())}get size(){return this._passParameters.size}set sizePx(e){this._passParameters.sizePx!==e&&(this._passParameters.sizePx=e,this._requestRender())}get sizePx(){return this._passParameters.sizePx}set clippingBox(e){f(this._passParameters.clipBox,e||P)}get _clippingEnabled(){return!b(this._passParameters.clipBox,P,((e,t)=>e===t))}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let s=null;return this._nodes.filterInPlace((i=>i.id!==e||(s=i,i.vao=t(i.vao),this._highlights.nodeRemoved(i),!1))),this._requestRender(),s}forEachNode(e){this._nodes.forAll(e)}removeAll(){this._nodes.forAll((e=>e.vao=t(e.vao))),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e,t){return this._highlights.add(e,t)}_addHighlight(e,t,s){e.addHighlight(t,s),this._requestRender()}_removeHighlight(e,t){e.removeHighlight(t),this._requestRender()}_initNode(e,t){t.vao??=new v(e.rctx,y,G,new Map([["positions",U.createVertex(e.rctx,W.STATIC_DRAW,t.coordinates)],["colors",U.createVertex(e.rctx,W.STATIC_DRAW,t.rgb)]]))}_requestRender(){this._context&&this._context.requestRender()}};e([i({constructOnly:!0})],V.prototype,"createGraphic",void 0),V=e([r("esri.views.3d.layers.i3s.PointRenderer")],V);class k extends N{constructor(e,t,s,i,r,n,o,a,h=null){super(s,r,t),this.id=e,this.obb=i,this.coordinates=n,this.rgb=o,this.attributes=a,this.pointIdFilterMap=h,this.highlights=null}addHighlight(e,t){let{highlights:s}=this;null==s&&(s=[],this.highlights=s);const i=new ee(e,t);s.push(i);const r=X(i);for(let n=s.length-1;n>0&&r<X(s[n-1]);--n)[s[n-1],s[n]]=[s[n],s[n-1]]}removeHighlight(e){const{highlights:t}=this;if(null==t)return;const s=t.filter((t=>t.id!==e));0===s.length&&(this.highlights=null),this.highlights=s}get cachedMemory(){return 5*this.coordinates.length+128}}function Q(e){return e.hasOwnProperty("splatSize")}function Y(e,t,s,i,r){if(s.drawScreenSpace)return s.fixedSize*t*i;const n=F(r)*t*i;return s.useFixedSizes?Math.min(s.fixedSize/2,n):s.screenMinSize>0?Math.min(Math.max(s.screenMinSize*t*i,e/2),n):Math.min(e/2,n)}function J(e,t,s,i,r){return s.drawScreenSpace?0:Y(e,t,s,i,r)}function K(e,t,s){return null==s&&(s=d()),s[0]=e.origin[0]+e.coordinates[3*t],s[1]=e.origin[1]+e.coordinates[3*t+1],s[2]=e.origin[2]+e.coordinates[3*t+2],s}function X(e){return null!=e.componentIndex?e.componentIndex:-1}class Z{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerUid=""}}function $(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}class ee{constructor(e,t){this.componentIndex=e,this.id=t}}export{V as PointRenderer,k as PointRendererNode,Q as isPointRendererNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{shuffle as t}from"../../../../core/arrayUtils.js";import{signal as e}from"../../../../core/signal.js";import{create as s,fromExtent as i,intersects as r,copy as u,positiveInfinity as a,intersection as h}from"../../../../geometry/support/aaBoundingRect.js";import{numVertices as n,estimateSize as f,getObjectId as l}from"../../../../layers/graphics/dehydratedFeatures.js";import{computeMaxZ as _}from"../graphics/graphicUtils.js";const d=16438,m=new Set;class F{constructor(t){this.descriptor=t,this.fetchStatus=o.FETCH_NEEDED,this.displayingFeatureResolution=0,this.fetchingFeatureResolution=0,this._featuresLength=e(0),this._numVertices=0,this._featuresMissing=e(!0),this._fetchFailed=e(!1),this._shuffled=!1,this._numFeatures=g,this._emptyFeatureRatio=e(0),this._estimatedSize=-1,this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._displayingFeatures=null,this.alive=!0,this.filtered=!1,this._features=null,this._featureLimit=e(0),this._availableFields=m,this.fetchingFeatureResolution=t.resolution,this.displayingFeatureResolution=t.resolution}get featuresMissing(){return this._featuresMissing.value}set featuresMissing(t){this._featuresMissing.value=t}get missingAttributes(){return this._missingAttributes}get fetchFailed(){return this._fetchFailed.value}set fetchFailed(t){this._fetchFailed.value=t}get displayingFeatures(){return this._displayingFeatures}set displayingFeatures(t){this._displayingFeatures=t,this.extentIncludingBorrowedFeatures=null}get perTileMaximumNumberOfFeaturesExceeded(){const t=(this.fetchStatus===o.DONE||this.fetchStatus===o.FULL)&&this.featuresMissing;return!this.filtered&&(t||this.hasFeatureLimit)}get features(){return this._features}get featureLimit(){return this._featureLimit.value}set featureLimit(t){this._featureLimit.value!==t&&(this._featureLimit.value=t,this._estimatedUnusedSizeDirty=!0)}get hasFeatureLimit(){return this.featureLimit!==this._featuresLength.value}get hasAllFeatures(){return!(this.featuresMissing||this.fetchFailed||this.hasFeatureLimit)}get availableFields(){return this._availableFields}setFeatures(t,e,s,i){this._availableFields=s??m,this._features=t,this._featuresLength.value=t?.length??0,this._shuffled=!1,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0,this._missingAttributes=i,t&&t.length>0?(this._emptyFeatureRatio.value=e/(t.length+e),this._numVertices=t.reduce(((t,e)=>t+n(e.geometry)),0)):(this._emptyFeatureRatio.value=0,this._numVertices=0)}computeZQuantizationFactor(){if(this._features&&this._features.length>0){const t=this._features.reduce(((t,{geometry:e})=>Math.max(t,_(e)??0)),0);return Math.floor(t/this.descriptor.planetRadius)+1}return 1}get emptyFeatureRatio(){return this._emptyFeatureRatio.value}get numFeatures(){return this.hasPreciseFeatureCount?this._numFeatures:this._features?this._features.length:0}set numFeatures(t){this._numFeatures=t}get hasPreciseFeatureCount(){return this._numFeatures>g}get needsFeatureCount(){return this._numFeatures===g}get numVertices(){return this._numVertices}get id(){return this.descriptor.id}get estimatedSize(){return this.updateMemoryEstimates(),this._estimatedSize}get estimatedUnusedSize(){return this._estimatedUnusedSize}updateMemoryEstimates(){if(this._estimatedSize<0){if(this._estimatedSize=0,this._estimatedUnusedSize=0,this._features)for(let t=0;t<this._features.length;++t){const e=f(this._features[t]);this._estimatedSize+=e,t>=this.featureLimit&&(this._estimatedUnusedSize+=e)}return!0}if(this._estimatedUnusedSizeDirty){if(this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._features)for(let t=this.featureLimit;t<this._features.length;++t)this._estimatedUnusedSize+=f(this._features[t]);return!0}return!1}get isFetching(){return this.fetchStatus===o.FETCHING||this.fetchStatus===o.REFETCHING}get isRefetching(){return this.fetchStatus===o.REFETCHING}get needsFetching(){return this.fetchStatus===o.FETCH_NEEDED||this.fetchStatus===o.REFETCH_NEEDED}get needsRefetching(){return this.fetchStatus===o.REFETCH_NEEDED}get isFetched(){return this.fetchStatus===o.DONE||this.fetchStatus===o.FULL}resetFetching(){this.fetchStatus=this.fetchStatus===o.REFETCHING?o.REFETCH_NEEDED:o.FETCH_NEEDED}get needsDisplayUpdate(){return!!this._features&&!E(this._features,this.displayingFeatures,this.featureLimit)}intersects(t){return null==t||!this.descriptor.extent||(i(t,S),r(this.descriptor.extent,S))}intersectionIncludingBorrowed(t,e){const s=null!=this.extentIncludingBorrowedFeatures?this.extentIncludingBorrowedFeatures:this.descriptor.extent;return t||s?(null!=t?(i(t,e),h(e,s,e)):u(e,s),e):(u(e,a),e)}_shuffle(e){this._features&&(this._features.sort(((t,s)=>l(t,e)-l(s,e))),t(this._features,d),this._shuffled=!0,this._estimatedUnusedSizeDirty=!0)}reduceFeatures(t,e,s){if(t<=0)return!1;if(!this._features)return this.featureLimit=0,!1;let i=!1;this.featureLimit=Math.ceil(this.numFeatures*t),this.featureLimit>this._features.length&&(this.featureLimit=this._features.length,this.fetchStatus===o.DONE&&this._features.length>0&&(this.fetchStatus=o.REFETCH_NEEDED,i=!0)),!this._shuffled&&t<1&&this._shuffle(s);const r=Math.max(this.featureLimit,Math.ceil(e*this.numFeatures));return this._features.length>r&&(this._features.length=r,this._featuresLength.value=r,this.featuresMissing=!0,this.fetchStatus===o.FULL&&(this.fetchStatus=o.DONE)),i}get cache(){return{availableFields:this._availableFields,features:this._features,numFeatures:this._numFeatures,emptyFeatureRatio:this._emptyFeatureRatio.value,fetchStatus:this.fetchStatus,featuresMissing:this.featuresMissing}}set cache(t){this.requestController=null,this._availableFields=t.availableFields,this._features=t.features,this._featuresLength.value=t.features?.length??0,this._numFeatures=t.numFeatures,this._emptyFeatureRatio.value=t.emptyFeatureRatio,this.fetchStatus=t.fetchStatus,this.featuresMissing=t.featuresMissing,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0}}const g=-1,c=-2;var o;function E(t,e,s){if(null==e||null==t||s!==e.length||s>t.length)return!1;for(let i=0;i<s;++i)if(t[i]!==e[i])return!1;return!0}!function(t){t[t.FETCH_NEEDED=0]="FETCH_NEEDED",t[t.REFETCH_NEEDED=1]="REFETCH_NEEDED",t[t.FETCHING=2]="FETCHING",t[t.REFETCHING=3]="REFETCHING",t[t.DONE=4]="DONE",t[t.FULL=5]="FULL"}(o||(o={}));const S=s();export{F as FeatureTile,o as FetchStatus,c as failedFeatureCount};
5
+ import{shuffle as t}from"../../../../core/arrayUtils.js";import{signal as e}from"../../../../core/signal.js";import{create as s,fromExtent as i,intersects as r,copy as u,positiveInfinity as a,intersection as h}from"../../../../geometry/support/aaBoundingRect.js";import{numVertices as n,estimateSize as f,getObjectId as l}from"../../../../layers/graphics/dehydratedFeatures.js";import{computeMaxZ as _}from"../graphics/graphicUtils.js";const d=16438,m=new Set;class F{constructor(t){this.descriptor=t,this.fetchStatus=o.FETCH_NEEDED,this.displayingFeatureResolution=0,this.fetchingFeatureResolution=0,this._featuresLength=e(0),this._numVertices=0,this._featuresMissing=e(!0),this._fetchFailed=e(!1),this._shuffled=!1,this._numFeatures=c,this._emptyFeatureRatio=e(0),this._estimatedSize=-1,this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._displayingFeatures=null,this.alive=!0,this.filtered=!1,this._features=null,this._featureLimit=e(0),this._availableFields=m,this.fetchingFeatureResolution=t.resolution,this.displayingFeatureResolution=t.resolution}get featuresMissing(){return this._featuresMissing.value}set featuresMissing(t){this._featuresMissing.value=t}get missingAttributes(){return this._missingAttributes}get fetchFailed(){return this._fetchFailed.value}set fetchFailed(t){this._fetchFailed.value=t}get displayingFeatures(){return this._displayingFeatures}set displayingFeatures(t){this._displayingFeatures=t,this.extentIncludingBorrowedFeatures=null}get perTileMaximumNumberOfFeaturesExceeded(){const t=(this.fetchStatus===o.DONE||this.fetchStatus===o.FULL)&&this.featuresMissing;return!this.filtered&&(t||this.hasFeatureLimit)}get features(){return this._features}get featureLimit(){return this._featureLimit.value}set featureLimit(t){this._featureLimit.value!==t&&(this._featureLimit.value=t,this._estimatedUnusedSizeDirty=!0)}get hasFeatureLimit(){return this.featureLimit!==this._featuresLength.value}get hasAllFeatures(){return!(this.featuresMissing||this.fetchFailed||this.hasFeatureLimit)}get availableFields(){return this._availableFields}setFeatures(t,e,s,i){this._availableFields=s??m,this._features=t,this._featuresLength.value=t?.length??0,this._shuffled=!1,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0,this._missingAttributes=i,t&&t.length>0?(this._emptyFeatureRatio.value=e/(t.length+e),this._numVertices=t.reduce(((t,e)=>t+n(e.geometry)),0)):(this._emptyFeatureRatio.value=0,this._numVertices=0)}computeZQuantizationFactor(){if(this._features&&this._features.length>0){const t=this._features.reduce(((t,{geometry:e})=>Math.max(t,_(e)??0)),0);return Math.floor(t/this.descriptor.planetRadius)+1}return 1}get emptyFeatureRatio(){return this._emptyFeatureRatio.value}get numFeatures(){return this.hasPreciseFeatureCount?this._numFeatures:this._features?this._features.length:0}set numFeatures(t){this._numFeatures=t}get hasPreciseFeatureCount(){return this._numFeatures>c}get needsFeatureCount(){return this._numFeatures===c}get numVertices(){return this._numVertices}get id(){return this.descriptor.id}get estimatedSize(){return this.updateMemoryEstimates(),this._estimatedSize}get estimatedUnusedSize(){return this._estimatedUnusedSize}updateMemoryEstimates(){if(this._estimatedSize<0){if(this._estimatedSize=0,this._estimatedUnusedSize=0,this._features)for(let t=0;t<this._features.length;++t){const e=f(this._features[t]);this._estimatedSize+=e,t>=this.featureLimit&&(this._estimatedUnusedSize+=e)}return!0}if(this._estimatedUnusedSizeDirty){if(this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._features)for(let t=this.featureLimit;t<this._features.length;++t)this._estimatedUnusedSize+=f(this._features[t]);return!0}return!1}get isFetching(){return this.fetchStatus===o.FETCHING||this.fetchStatus===o.REFETCHING}get isRefetching(){return this.fetchStatus===o.REFETCHING}get needsFetching(){return this.fetchStatus===o.FETCH_NEEDED||this.fetchStatus===o.REFETCH_NEEDED}get needsRefetching(){return this.fetchStatus===o.REFETCH_NEEDED}get isFetched(){return this.fetchStatus===o.DONE||this.fetchStatus===o.FULL}resetFetching(){this.fetchStatus=this.fetchStatus===o.REFETCHING?o.REFETCH_NEEDED:o.FETCH_NEEDED}get needsDisplayUpdate(){return!!this._features&&!E(this._features,this.displayingFeatures,this.featureLimit)}intersects(t){return null==t||!this.descriptor.extent||(i(t,S),r(this.descriptor.extent,S))}intersectionIncludingBorrowed(t,e){const s=null!=this.extentIncludingBorrowedFeatures?this.extentIncludingBorrowedFeatures:this.descriptor.extent;return t||s?(null!=t?(i(t,e),h(e,s,e)):u(e,s),e):(u(e,a),e)}_shuffle(e){this._features&&(this._features.sort(((t,s)=>l(t,e)-l(s,e))),t(this._features,d),this._shuffled=!0,this._estimatedUnusedSizeDirty=!0)}reduceFeatures(t,e,s){if(t<=0)return!1;if(!this._features)return this.featureLimit=0,!1;let i=!1;this.featureLimit=Math.ceil(this.numFeatures*t),this.featureLimit>this._features.length&&(this.featureLimit=this._features.length,this.fetchStatus===o.DONE&&this._features.length>0&&(this.fetchStatus=o.REFETCH_NEEDED,i=!0)),!this._shuffled&&t<1&&this._shuffle(s);const r=Math.max(this.featureLimit,Math.ceil(e*this.numFeatures));return this._features.length>r&&(this._features.length=r,this._featuresLength.value=r,this.featuresMissing=!0,this.fetchStatus===o.FULL&&(this.fetchStatus=o.DONE)),i}get cache(){const t=16+this.estimatedSize;return{availableFields:this._availableFields,features:this._features,numFeatures:this._numFeatures,emptyFeatureRatio:this._emptyFeatureRatio.value,fetchStatus:this.fetchStatus,featuresMissing:this.featuresMissing,cachedMemory:t}}set cache(t){this.requestController=null,this._availableFields=t.availableFields,this._features=t.features,this._featuresLength.value=t.features?.length??0,this._numFeatures=t.numFeatures,this._emptyFeatureRatio.value=t.emptyFeatureRatio,this.fetchStatus=t.fetchStatus,this.featuresMissing=t.featuresMissing,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0}}const c=-1,g=-2;var o;function E(t,e,s){if(null==e||null==t||s!==e.length||s>t.length)return!1;for(let i=0;i<s;++i)if(t[i]!==e[i])return!1;return!0}!function(t){t[t.FETCH_NEEDED=0]="FETCH_NEEDED",t[t.REFETCH_NEEDED=1]="REFETCH_NEEDED",t[t.FETCHING=2]="FETCHING",t[t.REFETCHING=3]="REFETCHING",t[t.DONE=4]="DONE",t[t.FULL=5]="FULL"}(o||(o={}));const S=s();export{F as FeatureTile,o as FetchStatus,g as failedFeatureCount};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import s from"../../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{isAbortError as r,throwIfAborted as a}from"../../../../core/promiseUtils.js";import n from"../../../../core/ReactiveMap.js";import{on as o,watch as u}from"../../../../core/reactiveUtils.js";import{schedule as l}from"../../../../core/scheduling.js";import{signal as h}from"../../../../core/signal.js";import{property as d}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as p,equals as f,clone as _,expand as m,toExtent as g}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as F,hasVertices as y}from"../../../../layers/graphics/dehydratedFeatures.js";import T from"../../../../rest/support/QuantizationParameters.js";import x from"../../../../rest/support/Query.js";import{ViewingMode as E}from"../../../ViewingMode.js";import{MultiFeatureReference as R,SingleFeatureReference as v}from"./featureReference.js";import{failedFeatureCount as C,FetchStatus as b,FeatureTile as D}from"./FeatureTile.js";import{tilesAreRelated as M}from"../../terrain/tileUtils.js";import{ImmediateTask as w,TaskPriority as U}from"../../../support/Scheduler.js";let O=class extends t{set maximumNumberOfFeatures(e){e=e||1/0;const t=this._get("maximumNumberOfFeatures");e===t||e<1||(this._set("maximumNumberOfFeatures",e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set("memoryFactor",e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set("lodFactor",e),this._supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&null!=this.context.query.queryFeatureCount}set useTileCount(e){this._useTileCount=e,this.notifyChange("useTileCount")}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get memoryForUnusedFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.estimatedUnusedSize)),e}get totalVertices(){let e=0;return this._featureTiles.forEach((t=>e+=t.numVertices)),e}get totalFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.numFeatures)),e}get hasAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(const e of this._featureTiles.values())if(!this.hasFullGeometries&&0!==e.emptyFeatureRatio||!e.hasAllFeatures)return!1;return!0}get hasFullGeometries(){if(!this._supportsResolution)return!0;return this.tileDescriptors.some(j)||!this.context.capabilities.supportsQuantization&&"polyline"!==this.context.geometryType}set filterExtent(e){if(null!=e&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference))return void s.getLogger(this).error("#filterExtent=","extent needs to be in the same spatial reference as the tiling scheme");const t=this._get("filterExtent");if(t===e||null!=t&&e&&t.equals(e))return;const i=null!=e?e.clone():null;this._set("filterExtent",i),this._reclip(i,t)}_updateTileZQuantization(e){if(this.context.viewingMode===E.Global){const t=e.computeZQuantizationFactor();this._zQuantizationFactor.value<t&&(this._zQuantizationFactor.value=t)}}get _tileZQuantization(){return this.context.isDraped?1:this._zQuantizationFactor.value}constructor(e){super(e),this._useTileCount=!1,this.dataUpdating=!1,this.running=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=h(1),this._changes={updates:{adds:new Array,removes:new Array},adds:new Array,removes:new Array},this._frameTask=w,this._featureTiles=new n,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this._isFetching=!1}initialize(){this.addHandles([o((()=>this.tileDescriptors),"change",(()=>this._setDirty()),{sync:!0,onListenerAdd:()=>this._setDirty()}),u((()=>this._tileZQuantization),(()=>this.refetch()))]),this._objectIdField=this.context.objectIdField,this.FeatureReferenceClass=this.context.capabilities.supportsMultipleResolutions?R:v;const e=this.context.scheduler;null!=e&&(this._frameTask=e.registerTask(U.FEATURE_TILE_FETCHER,this)),this._setDirty()}destroy(){this._frameTask.remove(),this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._removeTile(e)})),this._featureTiles.clear(),this._displayingFeatureReferences.clear(),this._pendingEdits?.controller.abort(),this._pendingEdits=null}get _paused(){return this._suspended||!!this._pendingEdits}restart(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(const t of this._featureTiles.values()){const s=t.missingAttributes?.get(e);if(null!=s)return s}}_pause(){this._paused&&(this._featureTiles.forEach((e=>this._cancelFetchTile(e))),this._updated())}_unpause(){this._paused||this._setDirty()}get availableFields(){let e=null;return this._featureTiles.forEach((t=>{null!=t.displayingFeatures&&0!==t.displayingFeatures.length&&(null==e?e=new Set(t.availableFields):e.forEach((s=>{t.availableFields.has(s)||e.delete(s)})))})),null!=e?e:new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());const t=this._pendingEdits;t.count++;const s=t.edits.then((()=>e.result.catch((e=>{if(r(e))throw e;return null})).then((e=>e?(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then((()=>e))):e)).then((e=>(0==--t.count&&(this._pendingEdits===t&&(this._pendingEdits=null),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)))));return t.edits=s,this._updated(),s}_applyEditsDeleteFeatures(e){if(0===e.length)return;const t=this.context.globalIdField,i=t&&this.availableFields.has(t),r=new Set,a=this._objectIdField;e.forEach((({objectId:e,globalId:n})=>{(!e||e<0)&&t&&n&&(i||s.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(n,a,t)),null!=e&&e>=0&&r.add(e)})),this._featureTiles.forEach((e=>{if(!e.features)return;const t=e.features.filter((e=>!r.has(F(e,this._objectIdField))));t.length!==e.features.length&&(this._applyEditsTileUpdated(),e.setFeatures(t,0,e.availableFields,e.missingAttributes),this._updateTileZQuantization(e),this._invalidateCounts())}))}_objectIdFromGlobalId(e,t,s){if(null==e)return null;const i=this.features.find((t=>t.attributes?.[s]===e));return i?F(i,t):null}async _applyEditsAddUpdateFeatures(e,t,i){const{objectIdField:r,globalIdField:a}=this.context,n=a&&this.availableFields.has(a),o=new Set,u=new Set;for(const s of e){const e=s.objectId;null!=e&&o.add(e)}for(const{objectId:h,globalId:d}of t){let e=h;(null==e||e<0)&&a&&(n||s.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${a} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(d,r,a)),null!=e&&e>=0&&(o.add(e),u.add(e))}if(0===o.size)return;const l=[];this._featureTiles.forEach((e=>{const t=this._applyEditsAddUpdateTile(e,o,u,i);t&&l.push(t)})),this._updated(),await Promise.allSettled(l)}async _applyEditsAddUpdateTile(e,t,s,i){if(!e.features)return;const r=this._createQuery(e);r.resultType=void 0,r.cacheHint=!1,r.objectIds=Array.from(t);const a=await this._queryFeatures(r,i);let n=null;if(s.size>0){const t=e.features.filter((e=>!s.has(F(e,this._objectIdField))));t.length!==e.features.length&&(n=t)}if(a.features.length>0){n||(n=e.features.slice());for(const e of a.features)n.push(e)}n&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,n.length)),this._applyEditsTileUpdated(),e.setFeatures(n,0,N(e.availableFields,a.fields),z(e.missingAttributes,a.missingAttributes)),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:q})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){const t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;const s=this._getListOfTiles();if(this._markTilesNotAlive(s),!e.run((()=>this._addTiles(s,e)))||!e.run((()=>this._filterExtentTiles(s,e)))||!e.run((()=>this._removeTiles(s,e)))||e.done)return void this._setDirty();const i=this._sortTiles(s);e.run((()=>this._showTiles(i,e)))&&e.run((()=>this._fetchTiles(i,e)))&&e.run((()=>this._updateMemoryEstimates(i,e)))||this._setDirty(),this._updated(),this.updating||this._updateMaximumNumberOfFeaturesExceeded()}_markTilesNotAlive(e){for(const t of e)t.alive=!1}_addTiles(e,t){return!(this._suspended||!this.tileDescriptors)&&(this.tileDescriptors.forEach((s=>{const i=this._featureTiles.get(s.id);i?i.alive=!0:t.done||(e.push(this._addTile(s)),t.madeProgress())})),t.hasProgressed)}_filterExtentTiles(e,t){for(const s of e){if(t.done)break;s.alive&&(s.filtered=!s.intersects(this.filterExtent),s.filtered&&(this._clearTile(s),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let s=e.length-1;s>=0&&!t.done;s--){const i=e[s];i.alive||(this._removeTile(i),s!==e.length-1&&(e[s]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort(((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority)),e}_showTiles(e,t){const s=this._updateRatio(e),i=e=>{const t=this._fullRatio<1?s(e)*this._farRatio:1;return e.reduceFeatures(t,this.memoryFactor,this._objectIdField)&&this._setDirty(),(e.features?.length??0)>0&&e.fetchingFeatureResolution!==e.descriptor.resolution&&e.fetchStatus===b.DONE&&(e.fetchStatus=b.REFETCH_NEEDED,this._setDirty()),this._showTile(e)};for(const r of e)if(!t.run((()=>i(r)))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let i=!1;for(const s of e){if(!s.needsFetching)continue;const e=null!=this.context.memoryCache?this.context.memoryCache.pop(s.id):null;if(null==e){if(this._needsNumFeatures(s)){const e=new AbortController,r=this._fetchTileCount(s,e.signal);this._handleRequest(s,r,e,(()=>s.numFeatures=C)),i=!0,t.madeProgress()}if(t.done)return!0}else s.cache=e,s.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress()}if(i)return t.hasProgressed;for(const r of e)if(r.needsFetching){const e=new AbortController,i=this._fetchTile(r,e.signal);if(this._handleRequest(r,i,e,(e=>{r.setFeatures([],0,null,void 0),this._invalidateCounts(),r.featuresMissing=!1,r.fetchFailed=!0,this.context.logFetchError(s.getLogger(this),e)})),t.madeProgress())return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some((e=>!t.run((()=>e.updateMemoryEstimates()))&&(this._setDirty(),!0))),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;const s=new Array;this._featureTiles.forEach((i=>{null!=i.displayingFeatures&&0!==i.displayingFeatures.length&&(i.intersectionIncludingBorrowed(t,S),i.intersectionIncludingBorrowed(e,L),f(S,L)||s.push(i))})),this._refreshDisplayingFeatures(s),this._updated()}_refreshDisplayingFeatures(e){const t=new Set,s=this._changes.updates;for(const i of e)if(null!=i.displayingFeatures)for(const e of i.displayingFeatures){const i=F(e,this._objectIdField);if(t.has(i))continue;t.add(i);const r=this._displayingFeatureReferences.get(i).feature;s.removes.push(r),s.adds.push(r)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach((t=>t.isFetching?++e:0)),this._isFetching=e>0,this._set("running",this._dirty),e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set("dataUpdating",!1),this.updating){let t=0,s=0,i=0,r=0,a=0;const n=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach((e=>{if(++s,e.isFetching&&e.hasPreciseFeatureCount){const t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),s=null!=e.displayingFeatures?e.displayingFeatures.length*n:0;a+=t-s}e.needsFetching?++r:e.numFeatures>0&&(++i,t+=e.numFeatures)})),r+=e;let o=0,u=0;t?(u=t,o=Math.min(r*t/i,t)):(u=s,o=r),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set("updatingTotal",u),this._set("updatingRemaining",o),this._set("expectedFeatureDiff",a)}else this._set("updatingTotal",0),this._set("updatingRemaining",0),this._set("expectedFeatureDiff",0);this.debugger&&this.debugger.update()}_updateMaximumNumberOfFeaturesExceeded(){for(const{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e)return void this._set("maximumNumberOfFeaturesExceeded",!0);this._set("maximumNumberOfFeaturesExceeded",!1)}_updateRatio(e){const t=A(e),s=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0]));let i=0,r=0;for(const a of e){const e=a.numFeatures;i+=e,r+=e*s(a)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/i),this._farRatio=this.maximumNumberOfFeatures/r,this._scheduleUpdated(),s}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach((e=>{if(!e.featuresMissing)return;const t=this._maximumFeaturesForTile(e);e.features&&(e.features.length>=t||e.fetchStatus===b.FULL)||(this._cancelFetchTile(e),this._resetFetchTile(e))})),this._setDirty())}_addTile(e){const t=new D(e);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){const t=e.displayingFeatureResolution;this._featureTiles.forEach((s=>{if(null!=s.displayingFeatures&&e!==s&&M(e.descriptor.lij,s.descriptor.lij)){null==e.displayingFeatures&&(e.displayingFeatures=[]),e.descriptor.extent&&s.descriptor.extent&&(null==e.extentIncludingBorrowedFeatures&&(e.extentIncludingBorrowedFeatures=_(e.descriptor.extent)),m(e.extentIncludingBorrowedFeatures,s.descriptor.extent,e.extentIncludingBorrowedFeatures));for(const i of s.displayingFeatures){e.displayingFeatures.push(i);const s=this._displayingFeatureReferences.get(F(i,this._objectIdField));s.ref(s.feature,t),this._numDisplayingFeatureReferences++}}})),e.featureLimit=null!=e.displayingFeatures?e.displayingFeatures.length:0}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetching&&(e.fetchStatus=b.DONE):e.fetchStatus=b.FETCH_NEEDED}_cancelFetchTile(e){const t=e.requestController;null!=t&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){return e.numFeatures=await this._fetchCount(e,t),this._updateRatio(this._getListOfTiles()),e.fetchStatus===b.REFETCHING?b.REFETCH_NEEDED:b.FETCH_NEEDED}async _fetchTile(e,t){e.fetchFailed=!1;const s=this._maximumFeaturesForTile(e);if(s<=0)return e.hasPreciseFeatureCount&&0===e.numFeatures||(e.fetchFailed=!0),I(e);const i=this._getMaxRecordCount(e),r=Math.ceil(s/i);if(j(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=s&&r>x.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);e.fetchingFeatureResolution=e.descriptor.resolution;const n=this._createQuery(e);if(n.maxRecordCountFactor=r,e.isRefetching&&e.features&&e.features.length>0){const t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/i);n.maxRecordCountFactor=Math.max(t+1,n.maxRecordCountFactor)}const{features:o,exceededTransferLimit:u,fields:l,missingAttributes:h}=await this._queryFeatures(n,t),d=u?n.maxRecordCountFactor>=x.MAX_MAX_RECORD_COUNT_FACTOR?b.FULL:b.DONE:b.FULL;return await this._frameTask.schedule((()=>{e.featuresMissing=e.hasPreciseFeatureCount&&o.length<e.numFeatures||!!u;const t=this._removeEmptyFeatures(o);e.setFeatures(o,t,P(l),z(void 0,h)),this._updateTileZQuantization(e)}),t),a(t),this._invalidateCounts(),d}async _fetchCount(e,t){return this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t})}async _fetchPagedTile(e,t){let s,i=0,r=0,n=0,o=this._maximumFeaturesForTile(e)-n;const u=this._getMaxRecordCount(e);let l,h=null;for(;;){const d=this._createQuery(e),c=this._setPagingParameters(d,i,o,u),{features:p,exceededTransferLimit:f,fields:_,missingAttributes:m}=await this._queryFeatures(d,t);if(await this._frameTask.schedule((()=>{c&&(i+=d.num),n+=p.length,r+=this._removeEmptyFeatures(p),e.featuresMissing=c&&e.hasPreciseFeatureCount&&i<e.numFeatures||!!f,s=s?s.concat(p):p,h=N(h,_),l=z(l,m),e.setFeatures(s,r,h,l),this._updateTileZQuantization(e)}),t),a(t),this._invalidateCounts(),this._setDirty(),o=this._maximumFeaturesForTile(e)-n,!c||!f||o<=0)return f?b.DONE:b.FULL}}_createFeatureCountQuery(e){const t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){const t=this.context.createQuery();return j(e)||(t.geometry=g(e.descriptor.extent,this.context.tilingScheme.spatialReference)),this._setResolutionParams(t,e),this._useTileQuery(e)?t.resultType="tile":this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),t}_setPagingParameters(e,t,s,i){return!!this.context.capabilities.supportsPagination&&(e.start=t,s>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(s/i),e.num=Math.min(e.maxRecordCountFactor*i,s)):e.num=Math.min(i),!0)}_getEffectiveTileResolution(e){if(j(e))return null;const t=this.context.viewingMode===E.Global?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingFeatureResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&"point"!==this.context.geometryType}_setResolutionParams(e,t){if(!this._supportsResolution)return;const s=this._getEffectiveTileResolution(t);null!=s&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new T({mode:"view",originPosition:"upper-left",tolerance:s,extent:this.context.fullExtent}):"polyline"===this.context.geometryType&&(e.maxAllowableOffset=s))}_removeEmptyFeatures(e){const t=e.length;for(let s=0;s<e.length;){const t=e[s];y(t.geometry)?++s:(e[s]=e[e.length-1],--e.length)}return t-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!j(e)}_getMaxRecordCount(e){const{tileMaxRecordCount:t,maxRecordCount:s}=this.context;return this._useTileQuery(e)&&null!=t&&t>0&&this.context.capabilities.supportsResultType?t:null!=s&&s>0?s:Q}_useTileQuery(e){return(!j(e)||!this.context.capabilities.supportsCacheHint)&&this.context.capabilities.supportsResultType}_handleRequest(e,t,s,i){e.fetchStatus=e.needsRefetching?b.REFETCHING:b.FETCHING,e.requestController=s;let a=!1;t.then((t=>{e.requestController=null,e.fetchStatus=t})).catch((t=>{e.requestController===s&&(e.requestController=null,e.fetchStatus=b.DONE),r(t)?a=!0:i(t)})).then((()=>{a||this._setDirty(),this._scheduleUpdated()}))}_scheduleUpdated(){this.hasHandles("scheduleUpdated")||this.addHandles(l((()=>{this.removeHandles("scheduleUpdated"),this._updated()})),"scheduleUpdated")}_showTile(e){if(null!=e.displayingFeatures&&!e.needsDisplayUpdate)return!1;const{features:t}=e;if(0===e.featureLimit||!t){const t=null!=e.displayingFeatures&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}const{fetchingFeatureResolution:s}=e,{adds:i,updates:r}=this._changes,a=Math.min(e.featureLimit,t.length);e.featureLimit=a;for(let n=0;n<a;++n){const e=t[n],a=F(e,this._objectIdField),o=this._displayingFeatureReferences.get(a);if(o){const{oldVersion:t,newVersion:i}=o.ref(e,s);t!==i&&(t&&r.removes.push(t),i&&r.adds.push(i))}else this._displayingFeatureReferences.set(a,new this.FeatureReferenceClass(e,s)),i.push(e);this._numDisplayingFeatureReferences++}return this._hideTileFeatures(e),e.displayingFeatureResolution=e.fetchingFeatureResolution,this._applyChanges(),e.displayingFeatures=t.slice(0,a),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(null==e.displayingFeatures)return;const{updates:t,removes:s}=this._changes;for(const i of e.displayingFeatures){const r=F(i,this._objectIdField),a=this._displayingFeatureReferences.get(r);if(!a)continue;const{oldVersion:n,newVersion:o}=a.unref(e.displayingFeatureResolution);this._numDisplayingFeatureReferences--,n!==o&&(null==o?(this._displayingFeatureReferences.delete(r),n&&s.push(n)):(t.adds.push(o),n&&t.removes.push(n)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get("dataUpdating")||this._set("dataUpdating",!0)}_applyChanges(){const e=this._changes.updates;e.removes.length>0&&(this._notifyDataUpdating(),this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this._notifyDataUpdating(),this.features.addMany(e.adds),e.adds.length=0);const t=this._changes.adds,s=this._changes.removes,i=Math.min(t.length,s.length);let r=0;for(;r<i;){const e=Math.min(r+H,i);this._notifyDataUpdating(),this.features.addMany(t.slice(r,e)),this.features.removeMany(s.slice(r,e)),r=e}t.length>i&&(this._notifyDataUpdating(),this.features.addMany(0===r?t:t.slice(r))),s.length>i&&(this._notifyDataUpdating(),this.features.removeMany(0===r?s:s.slice(r))),t.length=0,s.length=0}_clearTile(e){if(this._hideTile(e),e.features&&null!=this.context.memoryCache){const t=16+e.estimatedSize;this.context.memoryCache.put(e.id,e.cache,t)}e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange("totalVertices"),this.notifyChange("totalFeatures"),this.notifyChange("memoryForUnusedFeatures")}_getListOfTiles(){return Array.from(this._featureTiles.values())}get storedFeatures(){return this._getListOfTiles().reduce(((e,t)=>e+(t.features?t.features.length:0)),0)}get missingTiles(){return Array.from(this._featureTiles.values()).reduce(((e,t)=>e+(t.needsFetching||t.isFetching?1:0)),0)}_maximumFeaturesForTile(e){const t=e.hasPreciseFeatureCount?e.numFeatures:1/0,s=e.hasPreciseFeatureCount?t:this.maximumNumberOfFeatures,i=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(s*i/(1-e.emptyFeatureRatio)),t)}get test(){}};function j(e){return"dummy-tile-full-extent"===e.id}function A(e){let t=0;for(const s of e)s.features&&s.features.length>0&&s.alive&&(t=Math.max(t,s.descriptor.lij[0]));return t}function I(e){return e.setFeatures([],0,null,void 0),e.featuresMissing=!1,b.DONE}function P(e){return null==e?new Set:new Set(e.map((e=>e.name)))}function N(e,t){if(null==e||null==t)return P(t);const s=new Set;for(const{name:i}of t)e.has(i)&&s.add(i);return s}function z(e,t){if(!t?.length)return e;e??=new Map;const s=()=>new Set;for(const{objectId:r,attribute:a}of t)i(e,r,s).add(a);return e}e([d({constructOnly:!0})],O.prototype,"features",void 0),e([d()],O.prototype,"tileDescriptors",void 0),e([d({value:1/0})],O.prototype,"maximumNumberOfFeatures",null),e([d({value:1})],O.prototype,"memoryFactor",null),e([d({value:1})],O.prototype,"lodFactor",null),e([d()],O.prototype,"useTileCount",null),e([d({readOnly:!0})],O.prototype,"updating",null),e([d({readOnly:!0})],O.prototype,"dataUpdating",void 0),e([d({readOnly:!0})],O.prototype,"running",void 0),e([d({readOnly:!0})],O.prototype,"updatingTotal",void 0),e([d({readOnly:!0})],O.prototype,"updatingRemaining",void 0),e([d({readOnly:!0})],O.prototype,"expectedFeatureDiff",void 0),e([d({readOnly:!0})],O.prototype,"memoryForUnusedFeatures",null),e([d({readOnly:!0})],O.prototype,"maximumNumberOfFeaturesExceeded",void 0),e([d({readOnly:!0})],O.prototype,"totalVertices",null),e([d({readOnly:!0})],O.prototype,"totalFeatures",null),e([d({readOnly:!0})],O.prototype,"hasAllFeatures",null),e([d({readOnly:!0})],O.prototype,"hasFullGeometries",null),e([d()],O.prototype,"filterExtent",null),e([d({constructOnly:!0})],O.prototype,"context",void 0),e([d()],O.prototype,"_dirty",void 0),e([d()],O.prototype,"_suspended",void 0),e([d()],O.prototype,"_pendingEdits",void 0),e([d()],O.prototype,"_applyEditsTilesUpdated",void 0),e([d()],O.prototype,"_paused",null),e([d()],O.prototype,"_isFetching",void 0),O=e([c("esri.views.3d.layers.support.FeatureTileFetcher3D")],O);const Q=2e3,S=p(),L=p(),q=6e5,H=200;export{O as FeatureTileFetcher3D};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import s from"../../../../core/Logger.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{isAbortError as r,throwIfAborted as a}from"../../../../core/promiseUtils.js";import n from"../../../../core/ReactiveMap.js";import{on as o,watch as u}from"../../../../core/reactiveUtils.js";import{schedule as l}from"../../../../core/scheduling.js";import{signal as h}from"../../../../core/signal.js";import{property as d}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as p,equals as f,clone as _,expand as m,toExtent as g}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as F,hasVertices as y}from"../../../../layers/graphics/dehydratedFeatures.js";import T from"../../../../rest/support/QuantizationParameters.js";import x from"../../../../rest/support/Query.js";import{ViewingMode as E}from"../../../ViewingMode.js";import{MultiFeatureReference as R,SingleFeatureReference as v}from"./featureReference.js";import{failedFeatureCount as C,FetchStatus as b,FeatureTile as D}from"./FeatureTile.js";import{tilesAreRelated as M}from"../../terrain/tileUtils.js";import{ImmediateTask as w,TaskPriority as U}from"../../../support/Scheduler.js";let O=class extends t{set maximumNumberOfFeatures(e){e=e||1/0;const t=this._get("maximumNumberOfFeatures");e===t||e<1||(this._set("maximumNumberOfFeatures",e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set("memoryFactor",e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set("lodFactor",e),this._supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&null!=this.context.query.queryFeatureCount}set useTileCount(e){this._useTileCount=e,this.notifyChange("useTileCount")}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get memoryForUnusedFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.estimatedUnusedSize)),e}get totalVertices(){let e=0;return this._featureTiles.forEach((t=>e+=t.numVertices)),e}get totalFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.numFeatures)),e}get hasAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(const e of this._featureTiles.values())if(!this.hasFullGeometries&&0!==e.emptyFeatureRatio||!e.hasAllFeatures)return!1;return!0}get hasFullGeometries(){if(!this._supportsResolution)return!0;return this.tileDescriptors.some(j)||!this.context.capabilities.supportsQuantization&&"polyline"!==this.context.geometryType}set filterExtent(e){if(null!=e&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference))return void s.getLogger(this).error("#filterExtent=","extent needs to be in the same spatial reference as the tiling scheme");const t=this._get("filterExtent");if(t===e||null!=t&&e&&t.equals(e))return;const i=null!=e?e.clone():null;this._set("filterExtent",i),this._reclip(i,t)}_updateTileZQuantization(e){if(this.context.viewingMode===E.Global){const t=e.computeZQuantizationFactor();this._zQuantizationFactor.value<t&&(this._zQuantizationFactor.value=t)}}get _tileZQuantization(){return this.context.isDraped?1:this._zQuantizationFactor.value}constructor(e){super(e),this._useTileCount=!1,this.dataUpdating=!1,this.running=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=h(1),this._changes={updates:{adds:new Array,removes:new Array},adds:new Array,removes:new Array},this._frameTask=w,this._featureTiles=new n,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this._isFetching=!1}initialize(){this.addHandles([o((()=>this.tileDescriptors),"change",(()=>this._setDirty()),{sync:!0,onListenerAdd:()=>this._setDirty()}),u((()=>this._tileZQuantization),(()=>this.refetch()))]),this._objectIdField=this.context.objectIdField,this.FeatureReferenceClass=this.context.capabilities.supportsMultipleResolutions?R:v;const e=this.context.scheduler;null!=e&&(this._frameTask=e.registerTask(U.FEATURE_TILE_FETCHER,this)),this._setDirty()}destroy(){this._frameTask.remove(),this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._removeTile(e)})),this._featureTiles.clear(),this._displayingFeatureReferences.clear(),this._pendingEdits?.controller.abort(),this._pendingEdits=null}get _paused(){return this._suspended||!!this._pendingEdits}restart(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(const t of this._featureTiles.values()){const s=t.missingAttributes?.get(e);if(null!=s)return s}}_pause(){this._paused&&(this._featureTiles.forEach((e=>this._cancelFetchTile(e))),this._updated())}_unpause(){this._paused||this._setDirty()}get availableFields(){let e=null;return this._featureTiles.forEach((t=>{null!=t.displayingFeatures&&0!==t.displayingFeatures.length&&(null==e?e=new Set(t.availableFields):e.forEach((s=>{t.availableFields.has(s)||e.delete(s)})))})),null!=e?e:new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());const t=this._pendingEdits;t.count++;const s=t.edits.then((()=>e.result.catch((e=>{if(r(e))throw e;return null})).then((e=>e?(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then((()=>e))):e)).then((e=>(0==--t.count&&(this._pendingEdits===t&&(this._pendingEdits=null),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)))));return t.edits=s,this._updated(),s}_applyEditsDeleteFeatures(e){if(0===e.length)return;const t=this.context.globalIdField,i=t&&this.availableFields.has(t),r=new Set,a=this._objectIdField;e.forEach((({objectId:e,globalId:n})=>{(!e||e<0)&&t&&n&&(i||s.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(n,a,t)),null!=e&&e>=0&&r.add(e)})),this._featureTiles.forEach((e=>{if(!e.features)return;const t=e.features.filter((e=>!r.has(F(e,this._objectIdField))));t.length!==e.features.length&&(this._applyEditsTileUpdated(),e.setFeatures(t,0,e.availableFields,e.missingAttributes),this._updateTileZQuantization(e),this._invalidateCounts())}))}_objectIdFromGlobalId(e,t,s){if(null==e)return null;const i=this.features.find((t=>t.attributes?.[s]===e));return i?F(i,t):null}async _applyEditsAddUpdateFeatures(e,t,i){const{objectIdField:r,globalIdField:a}=this.context,n=a&&this.availableFields.has(a),o=new Set,u=new Set;for(const s of e){const e=s.objectId;null!=e&&o.add(e)}for(const{objectId:h,globalId:d}of t){let e=h;(null==e||e<0)&&a&&(n||s.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${a} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(d,r,a)),null!=e&&e>=0&&(o.add(e),u.add(e))}if(0===o.size)return;const l=[];this._featureTiles.forEach((e=>{const t=this._applyEditsAddUpdateTile(e,o,u,i);t&&l.push(t)})),this._updated(),await Promise.allSettled(l)}async _applyEditsAddUpdateTile(e,t,s,i){if(!e.features)return;const r=this._createQuery(e);r.resultType=void 0,r.cacheHint=!1,r.objectIds=Array.from(t);const a=await this._queryFeatures(r,i);let n=null;if(s.size>0){const t=e.features.filter((e=>!s.has(F(e,this._objectIdField))));t.length!==e.features.length&&(n=t)}if(a.features.length>0){n||(n=e.features.slice());for(const e of a.features)n.push(e)}n&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,n.length)),this._applyEditsTileUpdated(),e.setFeatures(n,0,N(e.availableFields,a.fields),Q(e.missingAttributes,a.missingAttributes)),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:q})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){const t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;const s=this._getListOfTiles();if(this._markTilesNotAlive(s),!e.run((()=>this._addTiles(s,e)))||!e.run((()=>this._filterExtentTiles(s,e)))||!e.run((()=>this._removeTiles(s,e)))||e.done)return void this._setDirty();const i=this._sortTiles(s);e.run((()=>this._showTiles(i,e)))&&e.run((()=>this._fetchTiles(i,e)))&&e.run((()=>this._updateMemoryEstimates(i,e)))||this._setDirty(),this._updated(),this.updating||this._updateMaximumNumberOfFeaturesExceeded()}_markTilesNotAlive(e){for(const t of e)t.alive=!1}_addTiles(e,t){return!(this._suspended||!this.tileDescriptors)&&(this.tileDescriptors.forEach((s=>{const i=this._featureTiles.get(s.id);i?i.alive=!0:t.done||(e.push(this._addTile(s)),t.madeProgress())})),t.hasProgressed)}_filterExtentTiles(e,t){for(const s of e){if(t.done)break;s.alive&&(s.filtered=!s.intersects(this.filterExtent),s.filtered&&(this._clearTile(s),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let s=e.length-1;s>=0&&!t.done;s--){const i=e[s];i.alive||(this._removeTile(i),s!==e.length-1&&(e[s]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort(((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority)),e}_showTiles(e,t){const s=this._updateRatio(e),i=e=>{const t=this._fullRatio<1?s(e)*this._farRatio:1;return e.reduceFeatures(t,this.memoryFactor,this._objectIdField)&&this._setDirty(),(e.features?.length??0)>0&&e.fetchingFeatureResolution!==e.descriptor.resolution&&e.fetchStatus===b.DONE&&(e.fetchStatus=b.REFETCH_NEEDED,this._setDirty()),this._showTile(e)};for(const r of e)if(!t.run((()=>i(r)))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let i=!1;for(const s of e){if(!s.needsFetching)continue;const e=null!=this.context.memoryCache?this.context.memoryCache.pop(s.id):null;if(null==e){if(this._needsNumFeatures(s)){const e=new AbortController,r=this._fetchTileCount(s,e.signal);this._handleRequest(s,r,e,(()=>s.numFeatures=C)),i=!0,t.madeProgress()}if(t.done)return!0}else s.cache=e,s.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress()}if(i)return t.hasProgressed;for(const r of e)if(r.needsFetching){const e=new AbortController,i=this._fetchTile(r,e.signal);if(this._handleRequest(r,i,e,(e=>{r.setFeatures([],0,null,void 0),this._invalidateCounts(),r.featuresMissing=!1,r.fetchFailed=!0,this.context.logFetchError(s.getLogger(this),e)})),t.madeProgress())return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some((e=>!t.run((()=>e.updateMemoryEstimates()))&&(this._setDirty(),!0))),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;const s=new Array;this._featureTiles.forEach((i=>{null!=i.displayingFeatures&&0!==i.displayingFeatures.length&&(i.intersectionIncludingBorrowed(t,S),i.intersectionIncludingBorrowed(e,L),f(S,L)||s.push(i))})),this._refreshDisplayingFeatures(s),this._updated()}_refreshDisplayingFeatures(e){const t=new Set,s=this._changes.updates;for(const i of e)if(null!=i.displayingFeatures)for(const e of i.displayingFeatures){const i=F(e,this._objectIdField);if(t.has(i))continue;t.add(i);const r=this._displayingFeatureReferences.get(i).feature;s.removes.push(r),s.adds.push(r)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach((t=>t.isFetching?++e:0)),this._isFetching=e>0,this._set("running",this._dirty),e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set("dataUpdating",!1),this.updating){let t=0,s=0,i=0,r=0,a=0;const n=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach((e=>{if(++s,e.isFetching&&e.hasPreciseFeatureCount){const t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),s=null!=e.displayingFeatures?e.displayingFeatures.length*n:0;a+=t-s}e.needsFetching?++r:e.numFeatures>0&&(++i,t+=e.numFeatures)})),r+=e;let o=0,u=0;t?(u=t,o=Math.min(r*t/i,t)):(u=s,o=r),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set("updatingTotal",u),this._set("updatingRemaining",o),this._set("expectedFeatureDiff",a)}else this._set("updatingTotal",0),this._set("updatingRemaining",0),this._set("expectedFeatureDiff",0);this.debugger&&this.debugger.update()}_updateMaximumNumberOfFeaturesExceeded(){for(const{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e)return void this._set("maximumNumberOfFeaturesExceeded",!0);this._set("maximumNumberOfFeaturesExceeded",!1)}_updateRatio(e){const t=A(e),s=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0]));let i=0,r=0;for(const a of e){const e=a.numFeatures;i+=e,r+=e*s(a)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/i),this._farRatio=this.maximumNumberOfFeatures/r,this._scheduleUpdated(),s}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach((e=>{if(!e.featuresMissing)return;const t=this._maximumFeaturesForTile(e);e.features&&(e.features.length>=t||e.fetchStatus===b.FULL)||(this._cancelFetchTile(e),this._resetFetchTile(e))})),this._setDirty())}_addTile(e){const t=new D(e);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){const t=e.displayingFeatureResolution;this._featureTiles.forEach((s=>{if(null!=s.displayingFeatures&&e!==s&&M(e.descriptor.lij,s.descriptor.lij)){null==e.displayingFeatures&&(e.displayingFeatures=[]),e.descriptor.extent&&s.descriptor.extent&&(null==e.extentIncludingBorrowedFeatures&&(e.extentIncludingBorrowedFeatures=_(e.descriptor.extent)),m(e.extentIncludingBorrowedFeatures,s.descriptor.extent,e.extentIncludingBorrowedFeatures));for(const i of s.displayingFeatures){e.displayingFeatures.push(i);const s=this._displayingFeatureReferences.get(F(i,this._objectIdField));s.ref(s.feature,t),this._numDisplayingFeatureReferences++}}})),e.featureLimit=null!=e.displayingFeatures?e.displayingFeatures.length:0}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetching&&(e.fetchStatus=b.DONE):e.fetchStatus=b.FETCH_NEEDED}_cancelFetchTile(e){const t=e.requestController;null!=t&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){return e.numFeatures=await this._fetchCount(e,t),this._updateRatio(this._getListOfTiles()),e.fetchStatus===b.REFETCHING?b.REFETCH_NEEDED:b.FETCH_NEEDED}async _fetchTile(e,t){e.fetchFailed=!1;const s=this._maximumFeaturesForTile(e);if(s<=0)return e.hasPreciseFeatureCount&&0===e.numFeatures||(e.fetchFailed=!0),I(e);const i=this._getMaxRecordCount(e),r=Math.ceil(s/i);if(j(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=s&&r>x.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);e.fetchingFeatureResolution=e.descriptor.resolution;const n=this._createQuery(e);if(n.maxRecordCountFactor=r,e.isRefetching&&e.features&&e.features.length>0){const t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/i);n.maxRecordCountFactor=Math.max(t+1,n.maxRecordCountFactor)}const{features:o,exceededTransferLimit:u,fields:l,missingAttributes:h}=await this._queryFeatures(n,t),d=u?n.maxRecordCountFactor>=x.MAX_MAX_RECORD_COUNT_FACTOR?b.FULL:b.DONE:b.FULL;return await this._frameTask.schedule((()=>{e.featuresMissing=e.hasPreciseFeatureCount&&o.length<e.numFeatures||!!u;const t=this._removeEmptyFeatures(o);e.setFeatures(o,t,P(l),Q(void 0,h)),this._updateTileZQuantization(e)}),t),a(t),this._invalidateCounts(),d}async _fetchCount(e,t){return this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t})}async _fetchPagedTile(e,t){let s,i=0,r=0,n=0,o=this._maximumFeaturesForTile(e)-n;const u=this._getMaxRecordCount(e);let l,h=null;for(;;){const d=this._createQuery(e),c=this._setPagingParameters(d,i,o,u),{features:p,exceededTransferLimit:f,fields:_,missingAttributes:m}=await this._queryFeatures(d,t);if(await this._frameTask.schedule((()=>{c&&(i+=d.num),n+=p.length,r+=this._removeEmptyFeatures(p),e.featuresMissing=c&&e.hasPreciseFeatureCount&&i<e.numFeatures||!!f,s=s?s.concat(p):p,h=N(h,_),l=Q(l,m),e.setFeatures(s,r,h,l),this._updateTileZQuantization(e)}),t),a(t),this._invalidateCounts(),this._setDirty(),o=this._maximumFeaturesForTile(e)-n,!c||!f||o<=0)return f?b.DONE:b.FULL}}_createFeatureCountQuery(e){const t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){const t=this.context.createQuery();return j(e)||(t.geometry=g(e.descriptor.extent,this.context.tilingScheme.spatialReference)),this._setResolutionParams(t,e),this._useTileQuery(e)?t.resultType="tile":this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),t}_setPagingParameters(e,t,s,i){return!!this.context.capabilities.supportsPagination&&(e.start=t,s>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(s/i),e.num=Math.min(e.maxRecordCountFactor*i,s)):e.num=Math.min(i),!0)}_getEffectiveTileResolution(e){if(j(e))return null;const t=this.context.viewingMode===E.Global?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingFeatureResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&"point"!==this.context.geometryType}_setResolutionParams(e,t){if(!this._supportsResolution)return;const s=this._getEffectiveTileResolution(t);null!=s&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new T({mode:"view",originPosition:"upper-left",tolerance:s,extent:this.context.fullExtent}):"polyline"===this.context.geometryType&&(e.maxAllowableOffset=s))}_removeEmptyFeatures(e){const t=e.length;for(let s=0;s<e.length;){const t=e[s];y(t.geometry)?++s:(e[s]=e[e.length-1],--e.length)}return t-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!j(e)}_getMaxRecordCount(e){const{tileMaxRecordCount:t,maxRecordCount:s}=this.context;return this._useTileQuery(e)&&null!=t&&t>0&&this.context.capabilities.supportsResultType?t:null!=s&&s>0?s:z}_useTileQuery(e){return(!j(e)||!this.context.capabilities.supportsCacheHint)&&this.context.capabilities.supportsResultType}_handleRequest(e,t,s,i){e.fetchStatus=e.needsRefetching?b.REFETCHING:b.FETCHING,e.requestController=s;let a=!1;t.then((t=>{e.requestController=null,e.fetchStatus=t})).catch((t=>{e.requestController===s&&(e.requestController=null,e.fetchStatus=b.DONE),r(t)?a=!0:i(t)})).then((()=>{a||this._setDirty(),this._scheduleUpdated()}))}_scheduleUpdated(){this.hasHandles("scheduleUpdated")||this.addHandles(l((()=>{this.removeHandles("scheduleUpdated"),this._updated()})),"scheduleUpdated")}_showTile(e){if(null!=e.displayingFeatures&&!e.needsDisplayUpdate)return!1;const{features:t}=e;if(0===e.featureLimit||!t){const t=null!=e.displayingFeatures&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}const{fetchingFeatureResolution:s}=e,{adds:i,updates:r}=this._changes,a=Math.min(e.featureLimit,t.length);e.featureLimit=a;for(let n=0;n<a;++n){const e=t[n],a=F(e,this._objectIdField),o=this._displayingFeatureReferences.get(a);if(o){const{oldVersion:t,newVersion:i}=o.ref(e,s);t!==i&&(t&&r.removes.push(t),i&&r.adds.push(i))}else this._displayingFeatureReferences.set(a,new this.FeatureReferenceClass(e,s)),i.push(e);this._numDisplayingFeatureReferences++}return this._hideTileFeatures(e),e.displayingFeatureResolution=e.fetchingFeatureResolution,this._applyChanges(),e.displayingFeatures=t.slice(0,a),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(null==e.displayingFeatures)return;const{updates:t,removes:s}=this._changes;for(const i of e.displayingFeatures){const r=F(i,this._objectIdField),a=this._displayingFeatureReferences.get(r);if(!a)continue;const{oldVersion:n,newVersion:o}=a.unref(e.displayingFeatureResolution);this._numDisplayingFeatureReferences--,n!==o&&(null==o?(this._displayingFeatureReferences.delete(r),n&&s.push(n)):(t.adds.push(o),n&&t.removes.push(n)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get("dataUpdating")||this._set("dataUpdating",!0)}_applyChanges(){const e=this._changes.updates;e.removes.length>0&&(this._notifyDataUpdating(),this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this._notifyDataUpdating(),this.features.addMany(e.adds),e.adds.length=0);const t=this._changes.adds,s=this._changes.removes,i=Math.min(t.length,s.length);let r=0;for(;r<i;){const e=Math.min(r+H,i);this._notifyDataUpdating(),this.features.addMany(t.slice(r,e)),this.features.removeMany(s.slice(r,e)),r=e}t.length>i&&(this._notifyDataUpdating(),this.features.addMany(0===r?t:t.slice(r))),s.length>i&&(this._notifyDataUpdating(),this.features.removeMany(0===r?s:s.slice(r))),t.length=0,s.length=0}_clearTile(e){this._hideTile(e),e.features&&null!=this.context.memoryCache&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange("totalVertices"),this.notifyChange("totalFeatures"),this.notifyChange("memoryForUnusedFeatures")}_getListOfTiles(){return Array.from(this._featureTiles.values())}get storedFeatures(){return this._getListOfTiles().reduce(((e,t)=>e+(t.features?t.features.length:0)),0)}get missingTiles(){return Array.from(this._featureTiles.values()).reduce(((e,t)=>e+(t.needsFetching||t.isFetching?1:0)),0)}_maximumFeaturesForTile(e){const t=e.hasPreciseFeatureCount?e.numFeatures:1/0,s=e.hasPreciseFeatureCount?t:this.maximumNumberOfFeatures,i=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(s*i/(1-e.emptyFeatureRatio)),t)}get test(){}};function j(e){return"dummy-tile-full-extent"===e.id}function A(e){let t=0;for(const s of e)s.features&&s.features.length>0&&s.alive&&(t=Math.max(t,s.descriptor.lij[0]));return t}function I(e){return e.setFeatures([],0,null,void 0),e.featuresMissing=!1,b.DONE}function P(e){return null==e?new Set:new Set(e.map((e=>e.name)))}function N(e,t){if(null==e||null==t)return P(t);const s=new Set;for(const{name:i}of t)e.has(i)&&s.add(i);return s}function Q(e,t){if(!t?.length)return e;e??=new Map;const s=()=>new Set;for(const{objectId:r,attribute:a}of t)i(e,r,s).add(a);return e}e([d({constructOnly:!0})],O.prototype,"features",void 0),e([d()],O.prototype,"tileDescriptors",void 0),e([d({value:1/0})],O.prototype,"maximumNumberOfFeatures",null),e([d({value:1})],O.prototype,"memoryFactor",null),e([d({value:1})],O.prototype,"lodFactor",null),e([d()],O.prototype,"useTileCount",null),e([d({readOnly:!0})],O.prototype,"updating",null),e([d({readOnly:!0})],O.prototype,"dataUpdating",void 0),e([d({readOnly:!0})],O.prototype,"running",void 0),e([d({readOnly:!0})],O.prototype,"updatingTotal",void 0),e([d({readOnly:!0})],O.prototype,"updatingRemaining",void 0),e([d({readOnly:!0})],O.prototype,"expectedFeatureDiff",void 0),e([d({readOnly:!0})],O.prototype,"memoryForUnusedFeatures",null),e([d({readOnly:!0})],O.prototype,"maximumNumberOfFeaturesExceeded",void 0),e([d({readOnly:!0})],O.prototype,"totalVertices",null),e([d({readOnly:!0})],O.prototype,"totalFeatures",null),e([d({readOnly:!0})],O.prototype,"hasAllFeatures",null),e([d({readOnly:!0})],O.prototype,"hasFullGeometries",null),e([d()],O.prototype,"filterExtent",null),e([d({constructOnly:!0})],O.prototype,"context",void 0),e([d()],O.prototype,"_dirty",void 0),e([d()],O.prototype,"_suspended",void 0),e([d()],O.prototype,"_pendingEdits",void 0),e([d()],O.prototype,"_applyEditsTilesUpdated",void 0),e([d()],O.prototype,"_paused",null),e([d()],O.prototype,"_isFetching",void 0),O=e([c("esri.views.3d.layers.support.FeatureTileFetcher3D")],O);const z=2e3,S=p(),L=p(),q=6e5,H=200;export{O as FeatureTileFetcher3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Camera.js";import"../../../geometry.js";import i from"../../../Viewpoint.js";import r from"../../../core/Accessor.js";import a from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{on as n,watch as o,sync as h,when as l}from"../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../core/scheduling.js";import{createScreenPoint as c}from"../../../core/screenUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{s as v}from"../../../chunks/vec32.js";import{fromArray as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as w}from"../../../chunks/vec42.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import _ from"../../../geometry/Extent.js";import y from"../../../geometry/Point.js";import{isLoadedOrLoadFor as f,requiresLoad as C}from"../../../geometry/projection.js";import{ViewingMode as x}from"../../ViewingMode.js";import{applyAll as R}from"../camera/constraintUtils.js";import{cameraOnContentAlongViewDirection as P,surfaceElevationBelowRenderLocation as S}from"../camera/intersectionUtils.js";import{ConstraintsManager as O}from"./ConstraintsManager.js";import{Frustum as T}from"./Frustum.js";import{GoToOperation as b}from"./GoToOperation.js";import{SurfaceCollisionCorrectionController as j}from"./controllers/SurfaceCollisionCorrectionController.js";import{internalToExternal as I,externalToInternal as M,toArea as z,toExtent as E,applyTiltAdjustToScale as A,scaleToZoom as H,fromExtentSync as L,OrientationMode as N,getObserverForPointAtDistanceSync as V,scaleToTargetDistance as B,zoomToScale as D}from"../support/cameraUtils.js";import{fromCamera as G,toCameraSync as U}from"../support/viewpointUtils.js";import F from"../webgl/RenderCamera.js";import{PaddingSide as k}from"../webgl-engine/lib/rendererUtils.js";import{RenderFeature as q}from"../webgl-engine/lib/RenderFeature.js";import{PropertiesPool as W}from"../../support/PropertiesPool.js";import{RenderState as J}from"../../support/RenderState.js";import{ensureAttachmentMaxSize as K}from"../../webgl/FramebufferObject.js";import Q from"../../../geometry/Polygon.js";let X=class extends r{constructor(e){super(e),this.ready=!1,this._windowDevicePixelRatio=1,this._devicePixelRatioOverride=null,this._idleTimeout=ne,this.test={viewStateManager:this,contentCameraResetState:new Map,setDevicePixelRatio:e=>this._devicePixelRatioOverride=e,renderState:null,get maximumPixelRatio(){return this.viewStateManager.view.qualitySettings.maximumPixelRatio},get updatingIgnoreRenderState(){return null!=this.renderState},get idleTimeoutEnabled(){return this.viewStateManager._idleTimeout>0},set idleTimeoutEnabled(e){this.viewStateManager._idleTimeout=e?ne:0}},this._propertiesPool=new W({frustum:T},this),this._cameraSetByUser=!1,this._gotoOperation=null,this._cameraChangeTime=0,this._tmpCanvasSize=new Y}initialize(){this._cameraChangeTime=performance.now(),this.addHandles([n((()=>this.view.state.events),"before-camera-change",(e=>e&&this._updateElevation(e))),o((()=>this.view.state?.camera),((e,t)=>this._cameraChangedHandler(e,t)),h)]),l((()=>this.view.state?.camera),(e=>this._updateElevation(e)),{once:!0,sync:!0}),this.addHandles([p({prepare:()=>this._prepareFrame()}),o((()=>this.view.state.cameraController),(()=>{this._cameraSetByUser=!0,this.removeHandles(ae)})),n((()=>this.view.state.events),"camera-projection-changed",(()=>this.notifyChange("scale")))])}destroy(){this.exit(),this._propertiesPool=s(this._propertiesPool)}get camera(){const e=this._get("camera");if(!this.ready)return e;const t=I(this.view,this.view.state.camera,te);return t&&e&&t.equals(e)?e:t.clone()}set camera(e){this._updatePropertyBeforeReady("camera",e)||(this.view.elevationProvider?.enableCache(!0),this.setStateCamera(M(this.view,e),{applyConstraints:!1})||a.getLogger(this).error("#camera=","Invalid camera",e),this.view.elevationProvider?.enableCache(!1))}get contentCamera(){const e=this._get("contentCamera");if(!this.ready)return e;const t=I(this.view,this.view.state.contentCamera,te);return t&&e&&t.equals(e)?e:t.clone()}set contentCamera(e){if(this._updatePropertyBeforeReady("contentCamera",e))return;const t=M(this.view,e);null!=t?(this._updateElevation(t),this.view.state.contentCamera=t):this.view.state.contentCamera=null}installContentCameraReset(e){if(this.removeHandles(se),this.test.contentCameraResetState.clear(),!this.view.state.fixedContentCamera)return!1;const t=this.zoom,i=this.view.state.camera.distance**2,r=u(this.view.state.camera.center),a=e.sticky?this.contentCamera.clone():null;return this.addHandles([o((()=>this.contentCamera),(()=>{e.sticky||(this.removeHandles(se),this.test.contentCameraResetState.clear())})),o((()=>this.zoom),(e=>{void 0!==e&&void 0!==t&&(this.test.contentCameraResetState.set("view.zoom",Math.abs(e-t)/2),Math.abs(e-t)>2?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a))})),o((()=>this.view.state.camera),(e=>{const t=v(r,e.center);this.test.contentCameraResetState.set("camera.center",t/i),t>i?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a)}))],se),!0}get center(){return this.ready?this.view.pointsOfInterest.centerOnContent.location:this._get("center")}set center(e){this._updatePropertyBeforeReady("center",e)||(e?this.isCompatible(e)?this.setStateCamera(this._centerToCamera(e),{applyConstraints:!0})?this.view.pointsOfInterest.centerOnContent.runTask():a.getLogger(this).error("#center=","Invalid center",e):a.getLogger(this).error("#center=","Center has an incompatible spatial reference (center: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this).error("#center=","Center may not be null or undefined"))}get visibleArea(){if(!this.ready){const e=this._get("extent");return e?Q.fromExtent(e):null}return z(this.view,this.view.pointsOfInterest.focus.renderLocation)}get extent(){if(!this.ready)return this._get("extent");const e=this.view,t=E(e,e.state.camera,e.pointsOfInterest.centerOnContent.renderLocation);return null!=t?t:this._get("extent")}set extent(e){this._updatePropertyBeforeReady("extent",e)||(e?this.isCompatible(e)?this.setStateCamera(this._extentToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#extent=","Invalid extent",e):a.getLogger(this).error("#extent=","Extent has an incompatible spatial reference (extent: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this).error("#extent=","Extent may not be null or undefined"))}get frustum(){const e=this._propertiesPool.get("frustum");return e.renderCoordsHelper=this.view.renderCoordsHelper,e.update(this.view.state.camera),e}get constraintsManager(){return this._constraintsManager}get _initialViewpoint(){const e=this.view.map;return e&&"initialViewProperties"in e?e.initialViewProperties?.viewpoint:void 0}get hasInitialView(){return!!this._initialViewpoint}get scale(){if(!this.ready)return this._get("scale");const e=this.view.basemapTerrain.tilingScheme,t=this.view.pointsOfInterest.cameraOnSurface.scale;return e&&t?A(this.view,t,this.view.state.contentCamera,e):this._get("scale")}set scale(e){this._updatePropertyBeforeReady("scale",e)||this.setStateCamera(this._scaleToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#scale=","Invalid scale",e)}get padding(){if(!this.ready)return this._get("padding");const e=this.view.state.camera,t=e.padding,i=e.pixelRatio,r=this._get("padding"),a=Math.round(t[k.TOP]/i),s=Math.round(t[k.RIGHT]/i),n=Math.round(t[k.BOTTOM]/i),o=Math.round(t[k.LEFT]/i);return null!=r&&r.top===a&&r.right===s&&r.bottom===n&&r.left===o?r:{top:a,right:s,bottom:n,left:o}}set padding(e){this._updatePropertyBeforeReady("padding",e)||(this._paddingToArray(e,this.view.state.camera.pixelRatio,re),this.view.state.updateCamera((e=>e.padding=re)))}_paddingToArray(e,t,i){e?w(i,e.top||0,e.right||0,e.bottom||0,e.left||0):w(i,0,0,0,0);for(let r=0;r<4;r++)i[r]=Math.round(i[r]*t)}get screenCenter(){const e=this.padding;return c((this.view.width-(e.left+e.right))/2+e.left,(this.view.height-(e.top+e.bottom))/2+e.top)}get viewpoint(){return this.ready?G(this.view,this.camera):this._get("viewpoint")}set viewpoint(e){if(!this._updatePropertyBeforeReady("viewpoint",e))if(e)if(this.isCompatible(e))this.setStateCamera(this._viewpointToCamera(e),{applyConstraints:!e.camera})||a.getLogger(this).error("#viewpoint=","Invalid viewpoint",e);else{const t=null!=e.camera?e.camera.position:e.targetGeometry,i=null!=t&&t.spatialReference;a.getLogger(this).error("#viewpoint=","Viewpoint has an incompatible spatial reference (viewpoint: "+(i?i.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e)}else a.getLogger(this).error("#viewpoint=","Viewpoint may not be null or undefined")}get zoom(){return this.ready?H(this.view,this.scale):this._get("zoom")}set zoom(e){this._updatePropertyBeforeReady("zoom",e)||void 0===e||this.setStateCamera(this._zoomToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#zoom=","Invalid zoom",e)}_computeCanvasSize(){if(this._devicePixelRatioOverride)return this.view.state.contentPixelRatio=this._devicePixelRatioOverride,this._tmpCanvasSize.width=Math.round(this.view.surface.clientWidth*this._devicePixelRatioOverride),this._tmpCanvasSize.height=Math.round(this.view.surface.clientHeight*this._devicePixelRatioOverride),this._tmpCanvasSize.pixelRatio=this._devicePixelRatioOverride,this._tmpCanvasSize;const e=Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio),t=(this._usePhysicalPixelRendering?this._windowDevicePixelRatio:e)*this.view.resolutionScale;this._tmpCanvasSize.width=Math.round(this.view.surface.clientWidth*t),this._tmpCanvasSize.height=Math.round(this.view.surface.clientHeight*t);const i=this.view._stage.renderView.renderingContext?.parameters.maxTextureSize;return i&&K(this._tmpCanvasSize,i),this._tmpCanvasSize.pixelRatio=this._tmpCanvasSize.width>0?this._tmpCanvasSize.width/this.view.surface.clientWidth*.5+this._tmpCanvasSize.height/this.view.surface.clientHeight*.5:t,this.view.state&&(this.view.state.contentPixelRatio=Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)),this._tmpCanvasSize}get _rasterPixelRatio(){return null!=this._devicePixelRatioOverride?this._devicePixelRatioOverride:this._usePhysicalPixelRenderingAny?this._windowDevicePixelRatio:Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)}get _usePhysicalPixelRendering(){return this.view?._stage?.renderer.isFeatureEnabled(q.PhysicalPixelRendering)??!1}get _usePhysicalPixelRenderingAny(){const e=this.view?._stage?.renderer;return e&&(e.isFeatureEnabled(q.PhysicalPixelRendering,J.IDLE)||e.isFeatureEnabled(q.PhysicalPixelRendering,J.INTERACTING)||e.isFeatureEnabled(q.PhysicalPixelRendering,J.ANIMATING))}preinit(e){return!(this._isOverridden("center")&&!f(this.center.spatialReference,e))&&(!(this._isOverridden("camera")&&!f(this.camera.position.spatialReference,e))&&(!(this._isOverridden("extent")&&!f(this.extent.spatialReference,e))&&!!(!this._isOverridden("viewpoint")||f(this.viewpoint.targetGeometry?.spatialReference,e)&&f(this.viewpoint.camera?.position?.spatialReference,e))))}init(){this._constraintsManager=new O({view:this.view}),this._prepareFrame();const e=this._getInitialProperties();this._cameraSetByUser=!1,this._set("ready",!0);for(const t of e)this.set(t.name,t.value);if(!this._cameraSetByUser){const e=this._initialViewpoint||this.view.initialExtent;e&&this.isCompatible(e)?this._setInitialView(e):this.view.state.viewingMode===x.Local&&this.addHandles(l((()=>this.view.basemapTerrain.ready),(()=>{this.removeHandles(ae),this._setInitialView(this.view.dataExtent)}),{once:!0,initial:!0}),ae)}}exit(){this._cancelGoToOperation(),this.ready&&(this._override("padding",this.padding),this._set("ready",!1),this._clearOverride("hasInitialView"),this._cameraSetByUser=!1,this.removeHandles(ae),this._constraintsManager=s(this._constraintsManager))}async goTo(e,t){return t={animate:!0,...t},null!=this._gotoOperation&&this._gotoOperation.abort(t.animate),this._gotoOperation=new b(e,t,this.view),this.view.resourceController.scheduler.stopFrame(),this._gotoOperation.promise}debugSetCameraOnContent(){this.setStateCamera(P(this.view),{applyConstraints:!1})}step(e){const t=this.view.state,i=t?.cameraController;i&&(t.updateCamera((t=>i.stepController(e,t))),i.steppingFinished&&i.finishController())}_cancelGoToOperation(){null!=this._gotoOperation&&(this._gotoOperation.abort(),this._gotoOperation=null)}_getInitialProperties(){const e=new Set,t=[];for(const{propertyName:i,overrides:r}of $){const a=e.has(i),s=this._isOverridden(i);!a&&s&&t.push({name:i,value:this._get(i)}),this._clearOverride(i),(a||s)&&r.forEach((t=>e.add(t)))}return t}_setInitialView(e){if(null==e||this._cameraSetByUser)return;if(e instanceof t)return void this.setStateCamera(M(this.view,e),{applyConstraints:!1});if(e instanceof i){if(e.targetGeometry instanceof _){const t=L(this.view,e.targetGeometry,0,.5,N.LOCKED);return void(null!=t&&this.setStateCamera(M(this.view,t),{applyConstraints:!0}))}const t={applyConstraints:!e.camera},i=this._viewpointToCamera(e);return void this.setStateCamera(i,t)}const r=L(this.view,e,0,.5,N.LOCKED);null!=r&&this.setStateCamera(M(this.view,r),{applyConstraints:!0})}_updatePropertyBeforeReady(e,t){return!this.ready&&(this._override(e,t),t&&Z.has(e)&&this._override("hasInitialView",!0),!0)}isCompatible(e){return null!=e&&(e instanceof i?e.camera?this.isCompatible(e.camera):this.isCompatible(e.targetGeometry):e instanceof t?this.isCompatible(e.position):e.spatialReference&&!C(e.spatialReference,this.view.spatialReference))}_getPreservingHeadingTilt(e=ee){return this._cameraSetByUser?(e.heading=this.camera.heading,e.tilt=this.camera.tilt):(e.heading=0,e.tilt=.5),e}_centerPointAtDistanceToCamera(e,t,i=ie){const{heading:r,tilt:a}=this._getPreservingHeadingTilt(),s=V(this.view,r,a,e,t,N.ADJUST);return null==s?null:(i.copyFrom(this.view.state.camera),i.eye=s.eye,i.center=s.center,i.up=s.up,i)}_centerToCamera(e){const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.distance;return this._centerPointAtDistanceToCamera(e,i)}_extentToCamera(e){const{heading:t,tilt:i}=this._getPreservingHeadingTilt(),r=L(this.view,e,t,i,N.ADJUST,te);return r?M(this.view,r):null}_scaleToCamera(e){if(null==e)return null;const t=this.view,i=t.pointsOfInterest.centerOnContent;i.runTask();const r=i.renderLocation,a=B(t,e,t.state.contentCamera,r);return this._centerPointAtDistanceToCamera(r,a)}_zoomToCamera(e){return this._scaleToCamera(D(this.view,e))}_viewpointToCamera(e){return M(this.view,U(this.view,e))}setStateCamera(e,t){return!(null==e||!this.view.state.stopActiveCameraController())&&(this._cameraSetByUser=!0,t.doNotCancelGoToOperation||this._cancelGoToOperation(),this.view.state.updateCamera((i=>{t.positionAndOrientationOnly?(i.eye=e.eye,i.center=e.center,i.up=e.up,i.fov=e.fov):i.copyFrom(e),t.applyConstraints&&R(this.view,i)})),t.applyConstraints||(this.view.state.cameraController=new j({view:this.view,desiredCamera:e})),!0)}_prepareFrame(){const{surface:e,canvas:t}=this.view;if(!e||!t)return;this._windowDevicePixelRatio=window.devicePixelRatio;const i=this._computeCanvasSize();if(0!==i.width&&0!==i.height&&(t.width===i.width&&t.height===i.height||(t.width=i.width,t.height=i.height),this.view.state)){const e=this.view.state.camera;e.fullWidth===i.width&&e.fullHeight===i.height&&e.pixelRatio===i.pixelRatio||(ie.copyFrom(e),ie.pixelRatio!==i.pixelRatio&&(this._paddingToArray(this.padding,i.pixelRatio,re),ie.padding=re),ie.fullWidth=i.width,ie.fullHeight=i.height,ie.pixelRatio=i.pixelRatio,this.view.state.camera=ie),this._updateViewState()}}_updateElevation(e){const t=this.view.basemapTerrain?.spatialReference,i=this.view.renderCoordsHelper?.getAltitude(e.eye)??0,r=t?S(this.view,e.eye):0;e.relativeElevation=i-r}_updateViewState(){null!=this.test.renderState?this.view.state.mode=this.test.renderState:this.view.animation?this.view.state.mode=J.ANIMATING:this.view.interacting?this.view.state.mode=J.INTERACTING:(this.view.state.mode===J.ANIMATING&&(this._cameraChangeTime=0),performance.now()-this._cameraChangeTime<this._idleTimeout?this.view.state.mode=J.INTERACTING:this.view.state.mode=J.IDLE),this.view.state.rasterPixelRatio=this._rasterPixelRatio}_cameraChangedHandler(e,t){e&&t&&e.almostEquals(t)||(this._cameraChangeTime=performance.now(),this._updateViewState())}};e([m({type:t,dependsOn:["view.state.camera","ready"]})],X.prototype,"camera",null),e([m({type:t,dependsOn:["view.state.contentCamera","ready"]})],X.prototype,"contentCamera",null),e([m({type:y})],X.prototype,"center",null),e([m()],X.prototype,"visibleArea",null),e([m({type:_})],X.prototype,"extent",null),e([m({readOnly:!0})],X.prototype,"frustum",null),e([m()],X.prototype,"_constraintsManager",void 0),e([m({readOnly:!0})],X.prototype,"constraintsManager",null),e([m()],X.prototype,"_initialViewpoint",null),e([m({readOnly:!0})],X.prototype,"hasInitialView",null),e([m({readOnly:!0,type:Boolean})],X.prototype,"ready",void 0),e([m({type:Number})],X.prototype,"scale",null),e([m()],X.prototype,"padding",null),e([m({readOnly:!0})],X.prototype,"screenCenter",null),e([m({constructOnly:!0})],X.prototype,"view",void 0),e([m({type:i})],X.prototype,"viewpoint",null),e([m({type:Number})],X.prototype,"zoom",null),e([m({readOnly:!0})],X.prototype,"_rasterPixelRatio",null),e([m({readOnly:!0})],X.prototype,"_usePhysicalPixelRendering",null),e([m({readOnly:!0})],X.prototype,"_usePhysicalPixelRenderingAny",null),e([m()],X.prototype,"_windowDevicePixelRatio",void 0),e([m()],X.prototype,"_devicePixelRatioOverride",void 0),X=e([d("esri.views.3d.state.ViewStateManager")],X);class Y{constructor(){this.width=0,this.height=0,this.pixelRatio=1}}const Z=new Set(["camera","viewpoint","extent","scale","center","zoom"]),$=[{propertyName:"camera",overrides:["viewpoint"]},{propertyName:"viewpoint",overrides:["extent"]},{propertyName:"extent",overrides:["center","scale"]},{propertyName:"center",overrides:[]},{propertyName:"scale",overrides:["zoom"]},{propertyName:"zoom",overrides:[]},{propertyName:"padding",overrides:[]}],ee={heading:0,tilt:0},te=new t,ie=new F,re=g(),ae="pending-initial-view",se="content-camera-reset",ne=300,oe=100;export{X as ViewStateManager,oe as interactingTimeout};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Camera.js";import"../../../geometry.js";import i from"../../../Viewpoint.js";import r from"../../../core/Accessor.js";import a from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{on as n,watch as o,sync as h,when as l}from"../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../core/scheduling.js";import{createScreenPoint as c}from"../../../core/screenUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{s as v}from"../../../chunks/vec32.js";import{fromArray as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as w}from"../../../chunks/vec42.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import _ from"../../../geometry/Extent.js";import y from"../../../geometry/Point.js";import{isLoadedOrLoadFor as f,requiresLoad as C}from"../../../geometry/projection.js";import{ViewingMode as x}from"../../ViewingMode.js";import{applyAll as R}from"../camera/constraintUtils.js";import{cameraOnContentAlongViewDirection as P,surfaceElevationBelowRenderLocation as S}from"../camera/intersectionUtils.js";import{ConstraintsManager as O}from"./ConstraintsManager.js";import{Frustum as T}from"./Frustum.js";import{GoToOperation as b}from"./GoToOperation.js";import{SurfaceCollisionCorrectionController as j}from"./controllers/SurfaceCollisionCorrectionController.js";import{internalToExternal as I,externalToInternal as M,toArea as z,toExtent as E,applyTiltAdjustToScale as A,scaleToZoom as H,fromExtentSync as L,OrientationMode as N,getObserverForPointAtDistanceSync as V,scaleToTargetDistance as B,zoomToScale as D}from"../support/cameraUtils.js";import{fromCamera as G,toCameraSync as U}from"../support/viewpointUtils.js";import F from"../webgl/RenderCamera.js";import{PaddingSide as k}from"../webgl-engine/lib/rendererUtils.js";import{RenderFeature as q}from"../webgl-engine/lib/RenderFeature.js";import{PropertiesPool as W}from"../../support/PropertiesPool.js";import{RenderState as J}from"../../support/RenderState.js";import{ensureAttachmentMaxSize as K}from"../../webgl/FramebufferObject.js";import Z from"../../../geometry/Polygon.js";let Q=class extends r{constructor(e){super(e),this.ready=!1,this._windowDevicePixelRatio=1,this._devicePixelRatioOverride=null,this._idleTimeout=ne,this.test={viewStateManager:this,contentCameraResetState:new Map,setDevicePixelRatio:e=>this._devicePixelRatioOverride=e,renderState:null,get maximumPixelRatio(){return this.viewStateManager.view.qualitySettings.maximumPixelRatio},get updatingIgnoreRenderState(){return null!=this.renderState},get idleTimeoutEnabled(){return this.viewStateManager._idleTimeout>0},set idleTimeoutEnabled(e){this.viewStateManager._idleTimeout=e?ne:0}},this._propertiesPool=new W({frustum:T},this),this._cameraSetByUser=!1,this._gotoOperation=null,this._cameraChangeTime=0,this._tmpCanvasSize=new X}initialize(){this._cameraChangeTime=performance.now(),this.addHandles([n((()=>this.view.state.events),"before-camera-change",(e=>e&&this._updateElevation(e))),o((()=>this.view.state?.camera),((e,t)=>this._cameraChangedHandler(e,t)),h)]),l((()=>this.view.state?.camera),(e=>this._updateElevation(e)),{once:!0,sync:!0}),this.addHandles([p({prepare:()=>this._prepareFrame()}),o((()=>this.view.state.cameraController),(()=>{this._cameraSetByUser=!0,this.removeHandles(ae)})),n((()=>this.view.state.events),"camera-projection-changed",(()=>this.notifyChange("scale")))])}destroy(){this.exit(),this._propertiesPool=s(this._propertiesPool)}get camera(){const e=this._get("camera");if(!this.ready)return e;const t=I(this.view,this.view.state.camera,te);return t&&e&&t.equals(e)?e:t.clone()}set camera(e){this._updatePropertyBeforeReady("camera",e)||(this.view.elevationProvider?.enableCache(!0),this.setStateCamera(M(this.view,e),{applyConstraints:!1})||a.getLogger(this).error("#camera=","Invalid camera",e),this.view.elevationProvider?.enableCache(!1))}get contentCamera(){const e=this._get("contentCamera");if(!this.ready)return e;const t=I(this.view,this.view.state.contentCamera,te);return t&&e&&t.equals(e)?e:t.clone()}set contentCamera(e){if(this._updatePropertyBeforeReady("contentCamera",e))return;const t=M(this.view,e);null!=t?(this._updateElevation(t),this.view.state.contentCamera=t):this.view.state.contentCamera=null}installContentCameraReset(e){if(this.removeHandles(se),this.test.contentCameraResetState.clear(),!this.view.state.fixedContentCamera)return!1;const t=this.zoom,i=this.view.state.camera.distance**2,r=u(this.view.state.camera.center),a=e.sticky?this.contentCamera.clone():null;return this.addHandles([o((()=>this.contentCamera),(()=>{e.sticky||(this.removeHandles(se),this.test.contentCameraResetState.clear())})),o((()=>this.zoom),(e=>{void 0!==e&&void 0!==t&&(this.test.contentCameraResetState.set("view.zoom",Math.abs(e-t)/2),Math.abs(e-t)>2?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a))})),o((()=>this.view.state.camera),(e=>{const t=v(r,e.center);this.test.contentCameraResetState.set("camera.center",t/i),t>i?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a)}))],se),!0}get center(){return this.ready?this.view.pointsOfInterest.centerOnContent.location:this._get("center")}set center(e){this._updatePropertyBeforeReady("center",e)||(e?this.isCompatible(e)?this.setStateCamera(this._centerToCamera(e),{applyConstraints:!0})?this.view.pointsOfInterest.centerOnContent.runTask():a.getLogger(this).error("#center=","Invalid center",e):a.getLogger(this).error("#center=","Center has an incompatible spatial reference (center: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this).error("#center=","Center may not be null or undefined"))}get visibleArea(){if(!this.ready){const e=this._get("extent");return e?Z.fromExtent(e):null}return z(this.view,this.view.pointsOfInterest.focus.renderLocation)}get extent(){if(!this.ready)return this._get("extent");const e=this.view,t=E(e,e.state.camera,e.pointsOfInterest.centerOnContent.renderLocation);return null!=t?t:this._get("extent")}set extent(e){this._updatePropertyBeforeReady("extent",e)||(e?this.isCompatible(e)?this.setStateCamera(this._extentToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#extent=","Invalid extent",e):a.getLogger(this).error("#extent=","Extent has an incompatible spatial reference (extent: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this).error("#extent=","Extent may not be null or undefined"))}get frustum(){const e=this._propertiesPool.get("frustum");return e.renderCoordsHelper=this.view.renderCoordsHelper,e.update(this.view.state.camera),e}get constraintsManager(){return this._constraintsManager}get _initialViewpoint(){const e=this.view.map;return e&&"initialViewProperties"in e?e.initialViewProperties?.viewpoint:void 0}get hasInitialView(){return!!this._initialViewpoint}get scale(){if(!this.ready)return this._get("scale");const e=this.view.basemapTerrain.tilingScheme,t=this.view.pointsOfInterest.cameraOnSurface.scale;return e&&t?A(this.view,t,this.view.state.contentCamera,e):this._get("scale")}set scale(e){this._updatePropertyBeforeReady("scale",e)||this.setStateCamera(this._scaleToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#scale=","Invalid scale",e)}get padding(){if(!this.ready)return this._get("padding");const e=this.view.state.camera,t=e.padding,i=e.pixelRatio,r=this._get("padding"),a=Math.round(t[k.TOP]/i),s=Math.round(t[k.RIGHT]/i),n=Math.round(t[k.BOTTOM]/i),o=Math.round(t[k.LEFT]/i);return null!=r&&r.top===a&&r.right===s&&r.bottom===n&&r.left===o?r:{top:a,right:s,bottom:n,left:o}}set padding(e){this._updatePropertyBeforeReady("padding",e)||(this._paddingToArray(e,this.view.state.camera.pixelRatio,re),this.view.state.updateCamera((e=>e.padding=re)))}_paddingToArray(e,t,i){e?w(i,e.top||0,e.right||0,e.bottom||0,e.left||0):w(i,0,0,0,0);for(let r=0;r<4;r++)i[r]=Math.round(i[r]*t)}get screenCenter(){const e=this.padding;return c((this.view.width-(e.left+e.right))/2+e.left,(this.view.height-(e.top+e.bottom))/2+e.top)}get viewpoint(){return this.ready?G(this.view,this.camera):this._get("viewpoint")}set viewpoint(e){if(!this._updatePropertyBeforeReady("viewpoint",e))if(e)if(this.isCompatible(e))this.setStateCamera(this._viewpointToCamera(e),{applyConstraints:!e.camera})||a.getLogger(this).error("#viewpoint=","Invalid viewpoint",e);else{const t=null!=e.camera?e.camera.position:e.targetGeometry,i=null!=t&&t.spatialReference;a.getLogger(this).error("#viewpoint=","Viewpoint has an incompatible spatial reference (viewpoint: "+(i?i.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e)}else a.getLogger(this).error("#viewpoint=","Viewpoint may not be null or undefined")}get zoom(){return this.ready?H(this.view,this.scale):this._get("zoom")}set zoom(e){this._updatePropertyBeforeReady("zoom",e)||void 0===e||this.setStateCamera(this._zoomToCamera(e),{applyConstraints:!0})||a.getLogger(this).error("#zoom=","Invalid zoom",e)}_computeCanvasSize(){if(this._devicePixelRatioOverride)return this.view.state.contentPixelRatio=this._devicePixelRatioOverride,this._tmpCanvasSize.width=Math.round(this.view.surface.clientWidth*this._devicePixelRatioOverride),this._tmpCanvasSize.height=Math.round(this.view.surface.clientHeight*this._devicePixelRatioOverride),this._tmpCanvasSize.pixelRatio=this._devicePixelRatioOverride,this._tmpCanvasSize;const e=Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio),t=(this._usePhysicalPixelRendering?this._windowDevicePixelRatio:e)*this.view.resolutionScale;this._tmpCanvasSize.width=Math.round(this.view.surface.clientWidth*t),this._tmpCanvasSize.height=Math.round(this.view.surface.clientHeight*t);const i=this.view._stage.renderView.renderingContext?.parameters.maxTextureSize;return i&&K(this._tmpCanvasSize,i),this._tmpCanvasSize.pixelRatio=this._tmpCanvasSize.width>0?this._tmpCanvasSize.width/this.view.surface.clientWidth*.5+this._tmpCanvasSize.height/this.view.surface.clientHeight*.5:t,this.view.state&&(this.view.state.contentPixelRatio=Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)),this._tmpCanvasSize}get _rasterPixelRatio(){return null!=this._devicePixelRatioOverride?this._devicePixelRatioOverride:this._usePhysicalPixelRenderingAny?this._windowDevicePixelRatio:Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)}get _usePhysicalPixelRendering(){return this.view?._stage?.renderer.isFeatureEnabled(q.PhysicalPixelRendering)??!1}get _usePhysicalPixelRenderingAny(){const e=this.view?._stage?.renderer;return e&&(e.isFeatureEnabled(q.PhysicalPixelRendering,J.IDLE)||e.isFeatureEnabled(q.PhysicalPixelRendering,J.INTERACTING)||e.isFeatureEnabled(q.PhysicalPixelRendering,J.ANIMATING))}preinit(e){return!(this._isOverridden("center")&&!f(this.center.spatialReference,e))&&(!(this._isOverridden("camera")&&!f(this.camera.position.spatialReference,e))&&(!(this._isOverridden("extent")&&!f(this.extent.spatialReference,e))&&!!(!this._isOverridden("viewpoint")||f(this.viewpoint.targetGeometry?.spatialReference,e)&&f(this.viewpoint.camera?.position?.spatialReference,e))))}init(){this._constraintsManager=new O({view:this.view}),this._prepareFrame();const e=this._getInitialProperties();this._cameraSetByUser=!1,this._set("ready",!0);for(const t of e)this.set(t.name,t.value);if(!this._cameraSetByUser){const e=this._initialViewpoint||this.view.initialExtent;e&&this.isCompatible(e)?this._setInitialView(e):this.view.state.viewingMode===x.Local&&this.addHandles(l((()=>this.view.basemapTerrain.ready),(()=>{this.removeHandles(ae),this._setInitialView(this.view.dataExtent)}),{once:!0,initial:!0}),ae)}}exit(){this._cancelGoToOperation(),this.ready&&(this._override("padding",this.padding),this._set("ready",!1),this._clearOverride("hasInitialView"),this._cameraSetByUser=!1,this.removeHandles(ae),this._constraintsManager=s(this._constraintsManager))}async goTo(e,t){return t={animate:!0,...t},null!=this._gotoOperation&&this._gotoOperation.abort(t.animate),this._gotoOperation=new b(e,t,this.view),this.view.resourceController.scheduler.stopFrame(),this._gotoOperation.promise}debugSetCameraOnContent(){this.setStateCamera(P(this.view),{applyConstraints:!1})}step(e){const t=this.view.state,i=t?.cameraController;i&&(t.updateCamera((t=>i.stepController(e,t))),i.steppingFinished&&i.finishController())}_cancelGoToOperation(){null!=this._gotoOperation&&(this._gotoOperation.abort(),this._gotoOperation=null)}_getInitialProperties(){const e=new Set,t=[];for(const{propertyName:i,overrides:r}of $){const a=e.has(i),s=this._isOverridden(i);!a&&s&&t.push({name:i,value:this._get(i)}),this._clearOverride(i),(a||s)&&r.forEach((t=>e.add(t)))}return t}_setInitialView(e){if(null==e||this._cameraSetByUser)return;if(e instanceof t)return void this.setStateCamera(M(this.view,e),{applyConstraints:!1});if(e instanceof i){if(e.targetGeometry instanceof _){const t=L(this.view,e.targetGeometry,0,.5,N.LOCKED);return void(null!=t&&this.setStateCamera(M(this.view,t),{applyConstraints:!0}))}const t={applyConstraints:!e.camera},i=this._viewpointToCamera(e);return void this.setStateCamera(i,t)}const r=L(this.view,e,0,.5,N.LOCKED);null!=r&&this.setStateCamera(M(this.view,r),{applyConstraints:!0})}_updatePropertyBeforeReady(e,t){return!this.ready&&(this._override(e,t),t&&Y.has(e)&&this._override("hasInitialView",!0),!0)}isCompatible(e){return null!=e&&(e instanceof i?e.camera?this.isCompatible(e.camera):this.isCompatible(e.targetGeometry):e instanceof t?this.isCompatible(e.position):e.spatialReference&&!C(e.spatialReference,this.view.spatialReference))}_getPreservingHeadingTilt(e=ee){return this._cameraSetByUser?(e.heading=this.camera.heading,e.tilt=this.camera.tilt):(e.heading=0,e.tilt=.5),e}_centerPointAtDistanceToCamera(e,t,i=ie){const{heading:r,tilt:a}=this._getPreservingHeadingTilt(),s=V(this.view,r,a,e,t,N.ADJUST);return null==s?null:(i.copyFrom(this.view.state.camera),i.eye=s.eye,i.center=s.center,i.up=s.up,i)}_centerToCamera(e){let t;if(e.hasZ)t=this.view.state.camera.distance;else{const{centerOnContent:e}=this.view.pointsOfInterest;e.runTask(),t=e.distance}return this._centerPointAtDistanceToCamera(e,t)}_extentToCamera(e){const{heading:t,tilt:i}=this._getPreservingHeadingTilt(),r=L(this.view,e,t,i,N.ADJUST,te);return r?M(this.view,r):null}_scaleToCamera(e){if(null==e)return null;const t=this.view,i=t.pointsOfInterest.centerOnContent;i.runTask();const r=i.renderLocation,a=B(t,e,t.state.contentCamera,r);return this._centerPointAtDistanceToCamera(r,a)}_zoomToCamera(e){return this._scaleToCamera(D(this.view,e))}_viewpointToCamera(e){return M(this.view,U(this.view,e))}setStateCamera(e,t){return!(null==e||!this.view.state.stopActiveCameraController())&&(this._cameraSetByUser=!0,t.doNotCancelGoToOperation||this._cancelGoToOperation(),this.view.state.updateCamera((i=>{t.positionAndOrientationOnly?(i.eye=e.eye,i.center=e.center,i.up=e.up,i.fov=e.fov):i.copyFrom(e),t.applyConstraints&&R(this.view,i)})),t.applyConstraints||(this.view.state.cameraController=new j({view:this.view,desiredCamera:e})),!0)}_prepareFrame(){const{surface:e,canvas:t}=this.view;if(!e||!t)return;this._windowDevicePixelRatio=window.devicePixelRatio;const i=this._computeCanvasSize();if(0!==i.width&&0!==i.height&&(t.width===i.width&&t.height===i.height||(t.width=i.width,t.height=i.height),this.view.state)){const e=this.view.state.camera;e.fullWidth===i.width&&e.fullHeight===i.height&&e.pixelRatio===i.pixelRatio||(ie.copyFrom(e),ie.pixelRatio!==i.pixelRatio&&(this._paddingToArray(this.padding,i.pixelRatio,re),ie.padding=re),ie.fullWidth=i.width,ie.fullHeight=i.height,ie.pixelRatio=i.pixelRatio,this.view.state.camera=ie),this._updateViewState()}}_updateElevation(e){const t=this.view.basemapTerrain?.spatialReference,i=this.view.renderCoordsHelper?.getAltitude(e.eye)??0,r=t?S(this.view,e.eye):0;e.relativeElevation=i-r}_updateViewState(){null!=this.test.renderState?this.view.state.mode=this.test.renderState:this.view.animation?this.view.state.mode=J.ANIMATING:this.view.interacting?this.view.state.mode=J.INTERACTING:(this.view.state.mode===J.ANIMATING&&(this._cameraChangeTime=0),performance.now()-this._cameraChangeTime<this._idleTimeout?this.view.state.mode=J.INTERACTING:this.view.state.mode=J.IDLE),this.view.state.rasterPixelRatio=this._rasterPixelRatio}_cameraChangedHandler(e,t){e&&t&&e.almostEquals(t)||(this._cameraChangeTime=performance.now(),this._updateViewState())}};e([m({type:t,dependsOn:["view.state.camera","ready"]})],Q.prototype,"camera",null),e([m({type:t,dependsOn:["view.state.contentCamera","ready"]})],Q.prototype,"contentCamera",null),e([m({type:y})],Q.prototype,"center",null),e([m()],Q.prototype,"visibleArea",null),e([m({type:_})],Q.prototype,"extent",null),e([m({readOnly:!0})],Q.prototype,"frustum",null),e([m()],Q.prototype,"_constraintsManager",void 0),e([m({readOnly:!0})],Q.prototype,"constraintsManager",null),e([m()],Q.prototype,"_initialViewpoint",null),e([m({readOnly:!0})],Q.prototype,"hasInitialView",null),e([m({readOnly:!0,type:Boolean})],Q.prototype,"ready",void 0),e([m({type:Number})],Q.prototype,"scale",null),e([m()],Q.prototype,"padding",null),e([m({readOnly:!0})],Q.prototype,"screenCenter",null),e([m({constructOnly:!0})],Q.prototype,"view",void 0),e([m({type:i})],Q.prototype,"viewpoint",null),e([m({type:Number})],Q.prototype,"zoom",null),e([m({readOnly:!0})],Q.prototype,"_rasterPixelRatio",null),e([m({readOnly:!0})],Q.prototype,"_usePhysicalPixelRendering",null),e([m({readOnly:!0})],Q.prototype,"_usePhysicalPixelRenderingAny",null),e([m()],Q.prototype,"_windowDevicePixelRatio",void 0),e([m()],Q.prototype,"_devicePixelRatioOverride",void 0),Q=e([d("esri.views.3d.state.ViewStateManager")],Q);class X{constructor(){this.width=0,this.height=0,this.pixelRatio=1}}const Y=new Set(["camera","viewpoint","extent","scale","center","zoom"]),$=[{propertyName:"camera",overrides:["viewpoint"]},{propertyName:"viewpoint",overrides:["extent"]},{propertyName:"extent",overrides:["center","scale"]},{propertyName:"center",overrides:[]},{propertyName:"scale",overrides:["zoom"]},{propertyName:"zoom",overrides:[]},{propertyName:"padding",overrides:[]}],ee={heading:0,tilt:0},te=new t,ie=new F,re=g(),ae="pending-initial-view",se="content-camera-reset",ne=300,oe=100;export{Q as ViewStateManager,oe as interactingTimeout};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import s from"../../../../Camera.js";import{deg2rad as r,rad2deg as e,clamp as i}from"../../../../core/mathUtils.js";import{destroyMaybe as a}from"../../../../core/maybe.js";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{g as n,h,c as l,d as c,n as m,j as _}from"../../../../chunks/vec32.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{pixelDistanceToInteractionFactor as u,applyAll as p}from"../../camera/constraintUtils.js";import{ConstraintOptions as f}from"../../camera/constraintUtils/ConstraintOptions.js";import{ConstraintTypes as y}from"../../camera/constraintUtils/ConstraintTypes.js";import{InteractionType as d}from"../../camera/constraintUtils/InteractionType.js";import{InteractiveController as g}from"./InteractiveController.js";import j from"../../../ui/Component.js";import{FovOverlay as S}from"../../../../widgets/FovOverlay.js";let w=class extends g{constructor(t){super(t),this._onReset=()=>{this._startSize=this._lastDrag=null,this._totalDelta=0,this._setFov(C)},this._center=v(),this._ray=v(),this._totalDelta=0,this._constraints=new f(y.ALL,d.ZOOM)}begin(t){b(t)?this._showOverlay().fov=t.fov:(this._lastDrag=t[1],this._startSize=null,this._ensureStartSize(this.view.state.camera))}update(t){if(null==this._lastDrag)return this._lastDrag=t[1],this._startSize=null,void this._ensureStartSize(this.view.state.camera);const s=-(this._lastDrag-t[1])/10;this._lastDrag=t[1],this.step(s)}step(t){if(!this.running)return void(this._startSize=this._lastDrag=null);const s=this.view.state,a=this.currentCamera.copyFrom(s.camera),o=e(a.fov)+this._totalDelta+t,n=o>O||o<z;this._totalDelta+=n?0:t;const h=Math.round((e(a.fov)+this._totalDelta)/D)*D,l=r(Math.round(i(h,z,O)));l!==a.fov&&(this._totalDelta=0,this._setFov(l))}finish(){this.running&&(this._startSize=this._lastDrag=null,this.finishController())}destroy(){this.hideOverlay()}onControllerEnd(t){super.onControllerEnd(t),this._startSize=this._lastDrag=null,this.hideOverlay()}_showOverlay(){return this._overlay||(this._overlay=new j({id:"esri.FovOverlay",node:new S({onReset:this._onReset})}),this.view.ui.add(this._overlay)),this._overlay.widget}hideOverlay(){this._overlay&&(this.view.ui.remove(this._overlay),this._overlay=a(this._overlay))}_setFov(t){const s=this.view.state,r=this.currentCamera.copyFrom(s.camera),e=this._ensureStartSize(r)/Math.tan(t/2),i=n(F,this._center,h(F,this._ray,e));r.eye=i,r.fov=t,this._constraints.interactionStartCamera=s.camera,this._constraints.interactionFactor=u(this.currentCamera.height-s.camera.height),p(this.view,this.currentCamera,this._constraints),this.begin(r),this.commitCamera()}_ensureStartSize(t){if(null==this._startSize){l(this._center,this.view.pointsOfInterest.centerOnContent.renderLocation),c(this._ray,t.eye,this._center),m(this._ray,this._ray);const s=_(t.eye,this._center);this._startSize=s*Math.tan(t.fov/2)}return this._startSize}};w=t([o("esri.views.3d.state.controllers.FovController")],w);const C=r((new s).fov),D=5,z=10,O=150,F=v();function b(t){return!Array.isArray(t)}export{w as FovController};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import s from"../../../../Camera.js";import{deg2rad as r,rad2deg as e,clamp as i}from"../../../../core/mathUtils.js";import{destroyMaybe as a}from"../../../../core/maybe.js";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{g as n,h,c as l,d as c,n as m,j as _}from"../../../../chunks/vec32.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{pixelDistanceToInteractionFactor as u,applyAll as f}from"../../camera/constraintUtils.js";import{ConstraintOptions as p}from"../../camera/constraintUtils/ConstraintOptions.js";import{ConstraintTypes as y}from"../../camera/constraintUtils/ConstraintTypes.js";import{InteractionType as d}from"../../camera/constraintUtils/InteractionType.js";import{InteractiveController as g}from"./InteractiveController.js";import j from"../../../ui/Component.js";import{FovOverlay as S}from"../../../../widgets/FovOverlay.js";let w=class extends g{constructor(t){super(t),this._onReset=()=>{this._startSize=this._lastDrag=null,this._totalDelta=0,this._setFov(C)},this._center=v(),this._ray=v(),this._totalDelta=0,this._constraints=new p(y.ALL,d.ZOOM)}begin(t){b(t)?this._showOverlay().fov=t.fov:(this._lastDrag=t[1],this._startSize=null,this._ensureStartSize(this.view.state.camera))}update(t){if(null==this._lastDrag)return this._lastDrag=t[1],this._startSize=null,void this._ensureStartSize(this.view.state.camera);const s=-(this._lastDrag-t[1])/10;this._lastDrag=t[1],this.step(s)}step(t){if(!this.running)return void(this._startSize=this._lastDrag=null);const s=this.view.state,a=this.currentCamera.copyFrom(s.camera),o=e(a.fov)+this._totalDelta+t,n=o>O||o<z;this._totalDelta+=n?0:t;const h=Math.round((e(a.fov)+this._totalDelta)/D)*D,l=r(Math.round(i(h,z,O)));l!==a.fov?(this._totalDelta=0,this._setFov(l)):this._showOverlay().fov=a.fov}finish(){this.running&&(this._startSize=this._lastDrag=null,this.finishController())}destroy(){this.hideOverlay()}onControllerEnd(t){super.onControllerEnd(t),this._startSize=this._lastDrag=null,this.hideOverlay()}_showOverlay(){return this._overlay||(this._overlay=new j({id:"esri.FovOverlay",node:new S({onReset:this._onReset})}),this.view.ui.add(this._overlay)),this._overlay.widget}hideOverlay(){this._overlay&&(this.view.ui.remove(this._overlay),this._overlay=a(this._overlay))}_setFov(t){const s=this.view.state,r=this.currentCamera.copyFrom(s.camera),e=this._ensureStartSize(r)/Math.tan(t/2),i=n(F,this._center,h(F,this._ray,e));r.eye=i,r.fov=t,this._constraints.interactionStartCamera=s.camera,this._constraints.interactionFactor=u(this.currentCamera.height-s.camera.height),f(this.view,this.currentCamera,this._constraints),this.begin(r),this.commitCamera()}_ensureStartSize(t){if(null==this._startSize){l(this._center,this.view.pointsOfInterest.centerOnContent.renderLocation),c(this._ray,t.eye,this._center),m(this._ray,this._ray);const s=_(t.eye,this._center);this._startSize=s*Math.tan(t.fov/2)}return this._startSize}};w=t([o("esri.views.3d.state.controllers.FovController")],w);const C=r((new s).fov),D=5,z=10,O=150,F=v();function b(t){return!Array.isArray(t)}export{w as FovController};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{BufferViewVec2f as e,BufferViewVec2f64 as t,BufferViewVec3f as s,BufferViewVec3f64 as i,BufferViewVec4f as r,BufferViewVec4f64 as n,BufferViewMat3f as h,BufferViewMat3f64 as d,BufferViewMat4f as u,BufferViewMat4f64 as f,BufferViewVec4u8 as l,BufferViewFloat as o,BufferViewFloat64 as p,BufferViewUint8 as c,BufferViewUint16 as a,BufferViewInt8 as _,BufferViewVec2i8 as y,BufferViewVec2i16 as m,BufferViewVec2u8 as F,BufferViewVec4u16 as g,BufferViewUint32 as b,BufferViewVec3u8 as w,BufferViewVec2u16 as v,BufferViewVec3u16 as E,BufferViewVec2u32 as A,BufferViewVec3u32 as T,BufferViewVec4u32 as M,BufferViewVec3i8 as B,BufferViewVec4i8 as U,BufferViewInt16 as z,BufferViewVec3i16 as C,BufferViewVec4i16 as L,BufferViewInt32 as j,BufferViewVec2i32 as x,BufferViewVec3i32 as $,BufferViewVec4i32 as V}from"../../../../geometry/support/buffer/BufferView.js";import{elementTypeSize as k}from"../../../../geometry/support/buffer/types.js";import{assert as q}from"../../webgl-engine/lib/Util.js";class D{constructor(e,t){this.layout=e,this.buffer="number"==typeof t?new ArrayBuffer(t*e.stride):t;for(const s of e.fields.keys()){const t=e.fields.get(s);this[s]=new t.constructor(this.buffer,t.offset,this.stride)}}get stride(){return this.layout.stride}get count(){return this.buffer.byteLength/this.stride}get byteLength(){return this.buffer.byteLength}getField(e,t){const s=this[e];return s&&s.elementCount===t.ElementCount&&s.elementType===t.ElementType?s:null}slice(e,t){return new D(this.layout,this.buffer.slice(e*this.stride,t*this.stride))}copyFrom(e,t=0,s=0,i=e.count){const r=this.stride;if(r%4==0){const n=new Uint32Array(e.buffer,t*r,i*r/4);new Uint32Array(this.buffer,s*r,i*r/4).set(n)}else{const n=new Uint8Array(e.buffer,t*r,i*r);new Uint8Array(this.buffer,s*r,i*r).set(n)}return this}get usedMemory(){return this.byteLength}dispose(){}}class G{constructor(e){this._stride=0,this._lastAligned=0,this._fields=new Map,e&&(this._stride=e.stride,e.fields.forEach((e=>this._fields.set(e[0],{...e[1],constructor:N(e[1].constructor)}))))}freeze(){return this}vec2f(t,s){return this._appendField(t,e,s),this}vec2f64(e,s){return this._appendField(e,t,s),this}vec3f(e,t){return this._appendField(e,s,t),this}vec3f64(e,t){return this._appendField(e,i,t),this}vec4f(e,t){return this._appendField(e,r,t),this}vec4f64(e,t){return this._appendField(e,n,t),this}mat3f(e,t){return this._appendField(e,h,t),this}mat3f64(e,t){return this._appendField(e,d,t),this}mat4f(e,t){return this._appendField(e,u,t),this}mat4f64(e,t){return this._appendField(e,f,t),this}vec4u8(e,t){return this._appendField(e,l,t),this}f32(e,t){return this._appendField(e,o,t),this}f64(e,t){return this._appendField(e,p,t),this}u8(e,t){return this._appendField(e,c,t),this}u16(e,t){return this._appendField(e,a,t),this}i8(e,t){return this._appendField(e,_,t),this}vec2i8(e,t){return this._appendField(e,y,t),this}vec2i16(e,t){return this._appendField(e,m,t),this}vec2u8(e,t){return this._appendField(e,F,t),this}vec4u16(e,t){return this._appendField(e,g,t),this}u32(e,t){return this._appendField(e,b,t),this}_appendField(e,t,s){if(this._fields.has(e))return void q(!1,`${e} already added to vertex buffer layout`);const i=t.ElementCount*k(t.ElementType),r=this._stride;this._stride+=i,this._fields.set(e,{size:i,constructor:t,offset:r,optional:s})}createBuffer(e){return new D(this,e)}createView(e){return new D(this,e)}clone(){const e=new G;return e._stride=this._stride,e._fields=new Map,this._fields.forEach(((t,s)=>e._fields.set(s,t))),e.BufferType=this.BufferType,e}get stride(){if(this._lastAligned!==this._fields.size){let e=1;this._fields.forEach((t=>e=Math.max(e,k(t.constructor.ElementType)))),this._stride=Math.floor((this._stride+e-1)/e)*e,this._lastAligned=this._fields.size}return this._stride}get fields(){return this._fields}}function H(){return new G}class I{constructor(e){this.fields=new Array,e.fields.forEach(((e,t)=>{const s={...e,constructor:K(e.constructor)};this.fields.push([t,s])})),this.stride=e.stride}}const J=[o,e,s,r,h,u,p,t,i,n,d,f,c,F,w,l,a,v,E,g,b,A,T,M,_,y,B,U,z,m,C,L,j,x,$,V];function K(e){return`${e.ElementType}_${e.ElementCount}`}function N(e){return O.get(e)}const O=new Map;J.forEach((e=>O.set(K(e),e)));export{D as InterleavedBuffer,G as InterleavedLayout,I as PackedLayout,H as newLayout};
5
+ import{BufferViewVec2f as e,BufferViewVec2f64 as t,BufferViewVec3f as i,BufferViewVec3f64 as s,BufferViewVec4f as r,BufferViewVec4f64 as n,BufferViewMat3f as h,BufferViewMat3f64 as d,BufferViewMat4f as u,BufferViewMat4f64 as f,BufferViewVec4u8 as l,BufferViewFloat as o,BufferViewFloat64 as p,BufferViewUint8 as c,BufferViewUint16 as a,BufferViewInt8 as _,BufferViewVec2i8 as y,BufferViewVec2i16 as m,BufferViewVec2u8 as F,BufferViewVec4u16 as g,BufferViewUint32 as b,BufferViewVec3u8 as w,BufferViewVec2u16 as v,BufferViewVec3u16 as E,BufferViewVec2u32 as A,BufferViewVec3u32 as T,BufferViewVec4u32 as M,BufferViewVec3i8 as B,BufferViewVec4i8 as U,BufferViewInt16 as z,BufferViewVec3i16 as C,BufferViewVec4i16 as L,BufferViewInt32 as j,BufferViewVec2i32 as x,BufferViewVec3i32 as $,BufferViewVec4i32 as V}from"../../../../geometry/support/buffer/BufferView.js";import{elementTypeSize as k}from"../../../../geometry/support/buffer/types.js";import{assert as q}from"../../webgl-engine/lib/Util.js";class D{constructor(e,t){this.layout=e,this.buffer="number"==typeof t?new ArrayBuffer(t*e.stride):t;for(const i of e.fields.keys()){const t=e.fields.get(i);this[i]=new t.constructor(this.buffer,t.offset,this.stride)}}get stride(){return this.layout.stride}get count(){return this.buffer.byteLength/this.stride}get byteLength(){return this.buffer.byteLength}getField(e,t){const i=this[e];return i&&i.elementCount===t.ElementCount&&i.elementType===t.ElementType?i:null}slice(e,t){return new D(this.layout,this.buffer.slice(e*this.stride,t*this.stride))}copyFrom(e,t=0,i=0,s=e.count){const r=this.stride;if(r%4==0){const n=new Uint32Array(e.buffer,t*r,s*r/4);new Uint32Array(this.buffer,i*r,s*r/4).set(n)}else{const n=new Uint8Array(e.buffer,t*r,s*r);new Uint8Array(this.buffer,i*r,s*r).set(n)}return this}get cachedMemory(){return this.byteLength}dispose(){}}class G{constructor(e){this._stride=0,this._lastAligned=0,this._fields=new Map,e&&(this._stride=e.stride,e.fields.forEach((e=>this._fields.set(e[0],{...e[1],constructor:N(e[1].constructor)}))))}freeze(){return this}vec2f(t,i){return this._appendField(t,e,i),this}vec2f64(e,i){return this._appendField(e,t,i),this}vec3f(e,t){return this._appendField(e,i,t),this}vec3f64(e,t){return this._appendField(e,s,t),this}vec4f(e,t){return this._appendField(e,r,t),this}vec4f64(e,t){return this._appendField(e,n,t),this}mat3f(e,t){return this._appendField(e,h,t),this}mat3f64(e,t){return this._appendField(e,d,t),this}mat4f(e,t){return this._appendField(e,u,t),this}mat4f64(e,t){return this._appendField(e,f,t),this}vec4u8(e,t){return this._appendField(e,l,t),this}f32(e,t){return this._appendField(e,o,t),this}f64(e,t){return this._appendField(e,p,t),this}u8(e,t){return this._appendField(e,c,t),this}u16(e,t){return this._appendField(e,a,t),this}i8(e,t){return this._appendField(e,_,t),this}vec2i8(e,t){return this._appendField(e,y,t),this}vec2i16(e,t){return this._appendField(e,m,t),this}vec2u8(e,t){return this._appendField(e,F,t),this}vec4u16(e,t){return this._appendField(e,g,t),this}u32(e,t){return this._appendField(e,b,t),this}_appendField(e,t,i){if(this._fields.has(e))return void q(!1,`${e} already added to vertex buffer layout`);const s=t.ElementCount*k(t.ElementType),r=this._stride;this._stride+=s,this._fields.set(e,{size:s,constructor:t,offset:r,optional:i})}createBuffer(e){return new D(this,e)}createView(e){return new D(this,e)}clone(){const e=new G;return e._stride=this._stride,e._fields=new Map,this._fields.forEach(((t,i)=>e._fields.set(i,t))),e.BufferType=this.BufferType,e}get stride(){if(this._lastAligned!==this._fields.size){let e=1;this._fields.forEach((t=>e=Math.max(e,k(t.constructor.ElementType)))),this._stride=Math.floor((this._stride+e-1)/e)*e,this._lastAligned=this._fields.size}return this._stride}get fields(){return this._fields}}function H(){return new G}class I{constructor(e){this.fields=new Array,e.fields.forEach(((e,t)=>{const i={...e,constructor:K(e.constructor)};this.fields.push([t,i])})),this.stride=e.stride}}const J=[o,e,i,r,h,u,p,t,s,n,d,f,c,F,w,l,a,v,E,g,b,A,T,M,_,y,B,U,z,m,C,L,j,x,$,V];function K(e){return`${e.ElementType}_${e.ElementCount}`}function N(e){return O.get(e)}const O=new Map;J.forEach((e=>O.set(K(e),e)));export{D as InterleavedBuffer,G as InterleavedLayout,I as PackedLayout,H as newLayout};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{d as s,k as n,f as r,h as a,g as o,l,c as h}from"../../../chunks/vec32.js";import{create as d,unitZ as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{create as g,equals as p}from"../../../geometry/support/aaBoundingRect.js";import{c as f,a as _}from"../../../chunks/sphere.js";import{isGroupLayer as m}from"../../../layers/support/layerUtils.js";import{ElevationBounds as y}from"./ElevationBounds.js";import{ElevationTileAgent as M,isElevationTileAgent as v}from"./ElevationTileAgent.js";import{TextureUpdate as A}from"./interfaces.js";import{LayerClasses as T,LayerClass as E}from"./LayerClass.js";import{MapTileAgent as D,isMapTileAgent as I}from"./MapTileAgent.js";import{NeighborIndex as L}from"./NeighborIndex.js";import{maxPatchTesselation as x}from"./TerrainConst.js";import{isVectorTile as S,isTileTexture as O,isRasterTile as N,isImageWithType as b}from"./TerrainData.js";import{weakAssert as j,isBlendableLayerView as U,oppositeCorner as B,internalAssert as P,enableTerrainInternalChecks as C,neighborEdgeIndices as R,oppositeEdge as w,neighborCornerIndices as V,isNorth as G,isSouth as q,isWest as F,isEast as H,almostEquals as W,enableWaterproofTests as k,isWestCorner as X,isNorthCorner as Y}from"./terrainUtils.js";import{tileAgentDone as z}from"./TileAgent.js";import{TileFrustumVisibility as J}from"./TileFrustumVisibility.js";import{TilePerLayerInfo as $}from"./TilePerLayerInfo.js";import{TileUpdate as Q}from"./TileUpdate.js";import{fallsWithinLayerView as K}from"./tileUtils.js";const Z=.1;class ee{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this.renderData=null,this._dirty=!0,this._previouslyRendered=!1,this.extent=g(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=g(),this.centerAtSeaLevel=d(),this._center=[d(),f(),d()],this.up=u(),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=d(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}static prune(){se.prune(0),ne.prune(0),$.prune()}get _cached(){return!this.leaf&&this._mapDataRefCount<=0}get withinClippingArea(){return this._withinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[ae.MIDDLE][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??J.INTERSECTS;this._frustumVisibility=t===J.INSIDE?J.INSIDE:t===J.OUTSIDE?J.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const i=this._frustumVisibility!==J.OUTSIDE&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=c(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[ae.MIDDLE][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.clearChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of T){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=$.acquire(this._surface.upsampleInfoPool),r===E.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,x)}dispose(){j(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key),this.layerInfo.forEach((e=>{e.forEach((e=>e.release())),e.length=0})),this._parent=null,this.clearChildren(),this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._cached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._cached){const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._cached?0:this._mapTileMemory)}get _cachedMemory(){return this._ensureUsedMemory(),this._cached?this._mapTileMemory:0}get _mapTileMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[E.MAP].reduce(((e,{data:t})=>e+(S(t)?t.usedMemoryPerReference:0)),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(const{data:t}of this.layerInfo[E.MAP])S(t)?this._vectorTileMemory+=t.usedMemoryPerReference:this._rasterTileMemory+=this._getTerrainDataMemory(t);const e=this._cpuImageMemorySize;for(const t of this.layerInfo[E.ELEVATION])this._usedMemory+=t.data?e:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.usedMemory??0),this._cached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemory),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===E.MAP?this._cached?0:this._getTerrainDataMemory(i.data):e===E.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return O(e)?e.texture.usedMemory:N(e)?e.memoryUsage:S(e)?e.usedMemoryPerReference:b(e)||e instanceof HTMLImageElement?this._cpuImageMemorySize:0}updateScreenDepth(e){const t=this._center[ae.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return Q.NONE;if(e.frustum&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===J.OUTSIDE))return Q.NONE;const h=this.level;s(ce,_(this._center[ae.MIDDLE]),t);let d=n(ce),u=ce,c=_(this._center[ae.MIDDLE]);s(ge,this._center[ae.TOP],t);const g=n(ge);g<d&&(d=g,u=ge,c=this._center[ae.TOP]),s(pe,this._center[ae.BOTTOM],t);const p=n(pe);if(p<d&&(d=p,u=pe,c=this._center[ae.BOTTOM]),this._edgeLen2>d&&h<e.maxLod)return Q.SPLIT;const f=Math.sqrt(d),m=e.fovX*f*2,y=this._edgeLen/m,M=()=>{if(h<e.maxLod)return this.elevationLevel=h,Q.NONE;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,Q.ELEVATION):Q.NONE},v=null!=i?i-h:1/0;if(v<=.5)return M();const A=r(this.up,ce),T=this._elevationBoundsMax-this._elevationBoundsMin,E=T/this.edgeLen;if(e.aboveGround&&A>0&&E<.001){if(A/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-E>0)return Q.NONE}const D=null!=i?3-Math.min(v,2):1;if(y*D<e.relativeWidthLimit||h>=e.maxLod)return M();if(h<7)return Q.SPLIT;a(fe,this.up,A),s(fe,fe,u);const I=n(fe);if(I<=this.radius*this.radius)return Q.SPLIT;a(fe,fe,this.radius/Math.sqrt(I)),o(fe,fe,c),s(fe,t,fe);const L=Math.min(1,(Math.abs(r(fe,this.up))+.5*T+this._curvatureHeight)/l(fe)),x=Z/e.angledSplitBias,S=e.fovY*f*2;return L*(this._edgeLen/S*D)<x*e.relativeHeightLimit?Q.NONE:Q.SPLIT}createChildren(){const e=this._children,t=this.lij[0]+1,i=2*this.lij[1],s=2*this.lij[2];return e[0]=this.surface.createTile(t,i,s,this),e[1]=this.surface.createTile(t,i,s+1,this),e[2]=this.surface.createTile(t,i+1,s,this),e[3]=this.surface.createTile(t,i+1,s+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get loaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of T)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){this.renderData&&this.unrefMapData(),e.unloadTile(this);for(const t of T){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==z&&(ie(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(Q.GEOMETRY),this.resetPendingUpdate(Q.TEXTURE_NOFADING),this.resetPendingUpdate(Q.TEXTURE_FADING)}unloadMapData(){const e=this.layerInfo[E.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==z&&(ie(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(p(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._withinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._withinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._withinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._withinClippingArea,n=!(i||t||this._withinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(Q.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of T){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==z&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(Q.SPLIT)||e!==E.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,e===Q.SPLIT||e===Q.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=S(n.data);return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get leaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(fe,_(this._center[ae.MIDDLE]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);j(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=S(i),n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll((e=>e.dataArrived(this,s))),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){const i=this.layerInfo[t][e];i.dataMissing=!0,i.waitingAgents.forAll((e=>e.dataMissing())),i.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor((i=>i.updateRenderData(e,t))),e){case E.MAP:return this._updateTexture(t);case E.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===A.FADING?Q.TEXTURE_NOFADING:Q.TEXTURE_FADING),this.setPendingUpdate(e===A.FADING?Q.TEXTURE_FADING:Q.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(Q.GEOMETRY);for(const e of this.layerInfo[E.ELEVATION])e.pendingUpdates|=Q.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[E.ELEVATION];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(fe,this.up,i),o(_(s[ae.MIDDLE]),this.centerAtSeaLevel,fe),a(fe,this.up,e),o(s[ae.TOP],this.centerAtSeaLevel,fe),a(fe,this.up,t),o(s[ae.BOTTOM],this.centerAtSeaLevel,fe)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[E.ELEVATION][e],s=this.elevationLevelDelta,n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,E.ELEVATION);if(!K(this,a))return;const o=re;let l=!1;const h=i.data;if(h&&h.level<=n){const e=i.data;o.min=e.samplerData.data.minValue,o.max=e.samplerData.data.maxValue,o.hasNoDataValues=e.samplerData.data.hasNoDataValues,o.level=this.level,l=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[E.ELEVATION][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],o),o.min!==1/0&&(o.level=i.level,l=!0))}l&&(null==i.elevationBounds&&(i.elevationBounds=new y),i.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==z&&(ie(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:$.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,A.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===z&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of T){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==z&&(i.loadingAgent.setSuspension(t),i.loadingAgent===z&&this.updateRenderData(e,A.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==z&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=z,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||m(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(U(e)&&"normal"!==e?.layer?.blendMode||m(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n],a=this._surface.layerViewByIndex(n,t);let o=!1;if(r.loadingAgent?K(this,a)?(r.loadingAgent!==z&&r.loadingAgent.setSuspension(s),r.loadingAgent!==z&&(o=r.loadingAgent.update())):r.dispose():K(this,a)&&(r.loadingAgent=te(this,n,t,s),o=r.loadingAgent.startLoading(),o?r.loadingAgent===z&&this.setPendingUpdate(Q.GEOMETRY):(ie(r.loadingAgent),r.loadingAgent=z)),r.loadingAgent===z&&this.updateRenderData(t,A.FADING),!this._hasBlendModes(e,i.length,t)&&o&&a.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,this.elevationLevelDelta-i),n=e(1+(this._maxTesselation>>s),2,this._maxTesselation+1),r=this.minimumVerticesPerSide;return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(oe(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.leaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this._getNeighborLIJ(i,e);return s?le(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===L.NORTH_EAST?1:e===L.NORTH_WEST?0:e===L.SOUTH_WEST?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)||null}forAllSubtreeOnSide(e,t){const i=e===L.NORTH?[0,1]:e===L.NORTH_EAST?[1]:e===L.EAST?[1,3]:e===L.SOUTH_EAST?[3]:e===L.SOUTH?[2,3]:e===L.SOUTH_WEST?[2]:e===L.WEST?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach((e=>s(n[e])))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(P(!C||i>=0),0===i)return 0;const s=2**i,n=!(1&~e),r=n?0:1,a=t.lij[r+1]*s,o=this._lij[r+1],l=o-a,h=n?s-1-l:l;return C&&(P(a<=o&&o<a+s),P(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.loaded;R.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(w(t),(i=>!!i.loaded&&(e(i,t),!0)))})),V.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.loaded));P(!s||he(this,s,t)),s?.loaded&&e(s,t)}))}_getNeighborLIJ(e,t){const i=G(t)?-1:q(t)?1:0,s=F(t)?-1:H(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this._wrapLIJ(n):n[2]<0?null:n}_wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}isEdgeNeighbor(e,t){if(null==e)return!1;if(0===this.level&&0===e.level){if(this._eastEnd&&e._westEnd&&t===L.EAST)return!0;if(this._westEnd&&e._eastEnd&&t===L.WEST)return!0}const i=Math.max(1e-6*(this.extent[2]-this.extent[0]),1);switch(t){case L.NORTH:return W(this.extent[3],e.extent[1],i);case L.SOUTH:return W(this.extent[1],e.extent[3],i);case L.EAST:return W(this.extent[2],e.extent[0],i)||W(this.extent[2],-e.extent[0],i);case L.WEST:return W(this.extent[0],e.extent[2],i)||W(this.extent[0],-e.extent[2],i)}}get _eastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get _westEnd(){return 0===this._lij[2]}checkGeometryWaterproofness(){k&&(P(this.loaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(G(e)&&t[3]+s>=i[3])return!1;if(q(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&F(e)&&t[0]-s<=i[0])&&!(!n&&H(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[ae.MIDDLE],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function te(e,t,i,s){const n=i===E.ELEVATION?ne.acquire():se.acquire();return n.init(e,t,i,s),n}function ie(e){e.dispose(),v(e)?ne.release(e):I(e)&&se.release(e)}const se=new i(D),ne=new i(M),re=new y;var ae;function oe(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function le(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function he(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?de(e,t,i):de(t,e,B(i)))}function de(e,t,i){P(e.level>=t.level);const s=X(i),n=Y(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),d=W(o[0],l[0],h)||e.surface.isGlobal&&W(o[0],-l[0],h),u=W(o[1],l[1],h);if(d&&u)return!0;if(e.level===t.level)return P(!1),!1;if(!d&&!u)return P(!1),!1;const c=d?ue(a[1],a[3],r[1],r[3],h):ue(a[0],a[2],r[0],r[2],h);return P(c),c}function ue(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(ae||(ae={}));const ce=d(),ge=d(),pe=d(),fe=d();export{ae as CenterPosition,ee as Tile,he as isCornerNeighbor,le as lijEquals};
5
+ import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{d as s,k as n,f as r,h as a,g as l,l as o,c as h}from"../../../chunks/vec32.js";import{create as d,unitZ as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{create as g,equals as p}from"../../../geometry/support/aaBoundingRect.js";import{c as f,a as _}from"../../../chunks/sphere.js";import{isGroupLayer as m}from"../../../layers/support/layerUtils.js";import{ElevationBounds as y}from"./ElevationBounds.js";import{ElevationTileAgent as M,isElevationTileAgent as v}from"./ElevationTileAgent.js";import{TextureUpdate as A}from"./interfaces.js";import{LayerClasses as T,LayerClass as E}from"./LayerClass.js";import{MapTileAgent as D,isMapTileAgent as I}from"./MapTileAgent.js";import{NeighborIndex as L}from"./NeighborIndex.js";import{maxPatchTesselation as x}from"./TerrainConst.js";import{isVectorTile as S,isTileTexture as O,isRasterTile as N,isImageWithType as b}from"./TerrainData.js";import{weakAssert as j,isBlendableLayerView as U,oppositeCorner as B,internalAssert as P,enableTerrainInternalChecks as C,neighborEdgeIndices as R,oppositeEdge as w,neighborCornerIndices as V,isNorth as G,isSouth as q,isWest as F,isEast as H,almostEquals as W,enableWaterproofTests as k,isWestCorner as X,isNorthCorner as Y}from"./terrainUtils.js";import{tileAgentDone as z}from"./TileAgent.js";import{TileFrustumVisibility as J}from"./TileFrustumVisibility.js";import{TilePerLayerInfo as $}from"./TilePerLayerInfo.js";import{TileUpdate as Q}from"./TileUpdate.js";import{fallsWithinLayerView as K}from"./tileUtils.js";const Z=.1;class ee{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this.renderData=null,this._dirty=!0,this._previouslyRendered=!1,this.extent=g(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=g(),this.centerAtSeaLevel=d(),this._center=[d(),f(),d()],this.up=u(),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=d(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}static prune(){se.prune(0),ne.prune(0),$.prune()}get _cached(){return!this.leaf&&this._mapDataRefCount<=0}get withinClippingArea(){return this._withinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[ae.MIDDLE][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??J.INTERSECTS;this._frustumVisibility=t===J.INSIDE?J.INSIDE:t===J.OUTSIDE?J.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const i=this._frustumVisibility!==J.OUTSIDE&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=c(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[ae.MIDDLE][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.clearChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of T){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=$.acquire(this._surface.upsampleInfoPool),r===E.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,x)}dispose(){null!=this._surface&&(j(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key),this.layerInfo.forEach((e=>{e.forEach((e=>e.release())),e.length=0})),this._surface=this._parent=null,this.clearChildren(),this.setMemoryDirty())}refMapData(){++this._mapDataRefCount,this._cached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){--this._mapDataRefCount,this._cached&&this.cachedMemory>0&&this._surface.upsampleMapCache.put(this.key,this)}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._cached?0:this._mapTileMemory)}get cachedMemory(){return this._ensureUsedMemory(),null==this._surface?this.usedMemory:this._cached?this._mapTileMemory:0}get _mapTileMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[E.MAP].reduce(((e,{data:t})=>e+(S(t)?t.usedMemoryPerReference:0)),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(const{data:e}of this.layerInfo[E.MAP])S(e)?this._vectorTileMemory+=e.usedMemoryPerReference:this._rasterTileMemory+=this._getTerrainDataMemory(e);for(const e of this.layerInfo[E.ELEVATION])this._usedMemory+=e.data?this._cpuImageMemorySize:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.cachedMemory??0),this._cached&&this._surface.upsampleMapCache.updateSize(this.key,this),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===E.MAP?this._cached?0:this._getTerrainDataMemory(i.data):e===E.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return O(e)?e.texture.usedMemory:N(e)?e.memoryUsage:S(e)?e.usedMemoryPerReference:b(e)||e instanceof HTMLImageElement?this._cpuImageMemorySize:0}updateScreenDepth(e){const t=this._center[ae.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return Q.NONE;if(e.frustum&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===J.OUTSIDE))return Q.NONE;const h=this.level;s(ce,_(this._center[ae.MIDDLE]),t);let d=n(ce),u=ce,c=_(this._center[ae.MIDDLE]);s(ge,this._center[ae.TOP],t);const g=n(ge);g<d&&(d=g,u=ge,c=this._center[ae.TOP]),s(pe,this._center[ae.BOTTOM],t);const p=n(pe);if(p<d&&(d=p,u=pe,c=this._center[ae.BOTTOM]),this._edgeLen2>d&&h<e.maxLod)return Q.SPLIT;const f=Math.sqrt(d),m=e.fovX*f*2,y=this._edgeLen/m,M=()=>{if(h<e.maxLod)return this.elevationLevel=h,Q.NONE;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,Q.ELEVATION):Q.NONE},v=null!=i?i-h:1/0;if(v<=.5)return M();const A=r(this.up,ce),T=this._elevationBoundsMax-this._elevationBoundsMin,E=T/this.edgeLen;if(e.aboveGround&&A>0&&E<.001){if(A/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-E>0)return Q.NONE}const D=null!=i?3-Math.min(v,2):1;if(y*D<e.relativeWidthLimit||h>=e.maxLod)return M();if(h<7)return Q.SPLIT;a(fe,this.up,A),s(fe,fe,u);const I=n(fe);if(I<=this.radius*this.radius)return Q.SPLIT;a(fe,fe,this.radius/Math.sqrt(I)),l(fe,fe,c),s(fe,t,fe);const L=Math.min(1,(Math.abs(r(fe,this.up))+.5*T+this._curvatureHeight)/o(fe)),x=Z/e.angledSplitBias,S=e.fovY*f*2;return L*(this._edgeLen/S*D)<x*e.relativeHeightLimit?Q.NONE:Q.SPLIT}createChildren(){const e=this._children,t=this.lij[0]+1,i=2*this.lij[1],s=2*this.lij[2];return e[0]=this.surface.createTile(t,i,s,this),e[1]=this.surface.createTile(t,i,s+1,this),e[2]=this.surface.createTile(t,i+1,s,this),e[3]=this.surface.createTile(t,i+1,s+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get loaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of T)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){this.renderData&&this.unrefMapData(),e.unloadTile(this);for(const t of T){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==z&&(ie(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(Q.GEOMETRY),this.resetPendingUpdate(Q.TEXTURE_NOFADING),this.resetPendingUpdate(Q.TEXTURE_FADING)}unloadMapData(){const e=this.layerInfo[E.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==z&&(ie(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(p(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._withinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._withinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._withinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._withinClippingArea,n=!(i||t||this._withinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(Q.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of T){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==z&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(Q.SPLIT)||e!==E.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,e===Q.SPLIT||e===Q.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=S(n.data);return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get leaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(fe,_(this._center[ae.MIDDLE]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);j(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=S(i),n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll((e=>e.dataArrived(this,s))),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){const i=this.layerInfo[t][e];i.dataMissing=!0,i.waitingAgents.forAll((e=>e.dataMissing())),i.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor((i=>i.updateRenderData(e,t))),e){case E.MAP:return this._updateTexture(t);case E.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===A.FADING?Q.TEXTURE_NOFADING:Q.TEXTURE_FADING),this.setPendingUpdate(e===A.FADING?Q.TEXTURE_FADING:Q.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(Q.GEOMETRY);for(const e of this.layerInfo[E.ELEVATION])e.pendingUpdates|=Q.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[E.ELEVATION];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(fe,this.up,i),l(_(s[ae.MIDDLE]),this.centerAtSeaLevel,fe),a(fe,this.up,e),l(s[ae.TOP],this.centerAtSeaLevel,fe),a(fe,this.up,t),l(s[ae.BOTTOM],this.centerAtSeaLevel,fe)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[E.ELEVATION][e],s=this.elevationLevelDelta,n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,E.ELEVATION);if(!K(this,a))return;const l=re;let o=!1;const h=i.data;if(h&&h.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,o=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[E.ELEVATION][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.min!==1/0&&(l.level=i.level,o=!0))}o&&(null==i.elevationBounds&&(i.elevationBounds=new y),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==z&&(ie(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:$.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,A.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===z&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of T){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==z&&(i.loadingAgent.setSuspension(t),i.loadingAgent===z&&this.updateRenderData(e,A.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==z&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=z,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||m(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(U(e)&&"normal"!==e?.layer?.blendMode||m(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n],a=this._surface.layerViewByIndex(n,t);let l=!1;if(r.loadingAgent?K(this,a)?(r.loadingAgent!==z&&r.loadingAgent.setSuspension(s),r.loadingAgent!==z&&(l=r.loadingAgent.update())):r.dispose():K(this,a)&&(r.loadingAgent=te(this,n,t,s),l=r.loadingAgent.startLoading(),l?r.loadingAgent===z&&this.setPendingUpdate(Q.GEOMETRY):(ie(r.loadingAgent),r.loadingAgent=z)),r.loadingAgent===z&&this.updateRenderData(t,A.FADING),!this._hasBlendModes(e,i.length,t)&&l&&a.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,this.elevationLevelDelta-i),n=e(1+(this._maxTesselation>>s),2,this._maxTesselation+1),r=this.minimumVerticesPerSide;return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(le(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.leaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this._getNeighborLIJ(i,e);return s?oe(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===L.NORTH_EAST?1:e===L.NORTH_WEST?0:e===L.SOUTH_WEST?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)||null}forAllSubtreeOnSide(e,t){const i=e===L.NORTH?[0,1]:e===L.NORTH_EAST?[1]:e===L.EAST?[1,3]:e===L.SOUTH_EAST?[3]:e===L.SOUTH?[2,3]:e===L.SOUTH_WEST?[2]:e===L.WEST?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach((e=>s(n[e])))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(P(!C||i>=0),0===i)return 0;const s=2**i,n=!(1&~e),r=n?0:1,a=t.lij[r+1]*s,l=this._lij[r+1],o=l-a,h=n?s-1-o:o;return C&&(P(a<=l&&l<a+s),P(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.loaded;R.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(w(t),(i=>!!i.loaded&&(e(i,t),!0)))})),V.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.loaded));P(!s||he(this,s,t)),s?.loaded&&e(s,t)}))}_getNeighborLIJ(e,t){const i=G(t)?-1:q(t)?1:0,s=F(t)?-1:H(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this._wrapLIJ(n):n[2]<0?null:n}_wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}isEdgeNeighbor(e,t){if(null==e)return!1;if(0===this.level&&0===e.level){if(this._eastEnd&&e._westEnd&&t===L.EAST)return!0;if(this._westEnd&&e._eastEnd&&t===L.WEST)return!0}const i=Math.max(1e-6*(this.extent[2]-this.extent[0]),1);switch(t){case L.NORTH:return W(this.extent[3],e.extent[1],i);case L.SOUTH:return W(this.extent[1],e.extent[3],i);case L.EAST:return W(this.extent[2],e.extent[0],i)||W(this.extent[2],-e.extent[0],i);case L.WEST:return W(this.extent[0],e.extent[2],i)||W(this.extent[0],-e.extent[2],i)}}get _eastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get _westEnd(){return 0===this._lij[2]}checkGeometryWaterproofness(){k&&(P(this.loaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(G(e)&&t[3]+s>=i[3])return!1;if(q(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&F(e)&&t[0]-s<=i[0])&&!(!n&&H(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[ae.MIDDLE],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function te(e,t,i,s){const n=i===E.ELEVATION?ne.acquire():se.acquire();return n.init(e,t,i,s),n}function ie(e){e.dispose(),v(e)?ne.release(e):I(e)&&se.release(e)}const se=new i(D),ne=new i(M),re=new y;var ae;function le(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function oe(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function he(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?de(e,t,i):de(t,e,B(i)))}function de(e,t,i){P(e.level>=t.level);const s=X(i),n=Y(i),r=e.extent,a=t.extent,l=[s?r[0]:r[2],n?r[3]:r[1]],o=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),d=W(l[0],o[0],h)||e.surface.isGlobal&&W(l[0],-o[0],h),u=W(l[1],o[1],h);if(d&&u)return!0;if(e.level===t.level)return P(!1),!1;if(!d&&!u)return P(!1),!1;const c=d?ue(a[1],a[3],r[1],r[3],h):ue(a[0],a[2],r[0],r[2],h);return P(c),c}function ue(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(ae||(ae={}));const ce=d(),ge=d(),pe=d(),fe=d();export{ae as CenterPosition,ee as Tile,he as isCornerNeighbor,oe as lijEquals};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- class t{constructor(t,e){this._texture=t,this._cache=e,this.type="tile-texture",this._refCount=1}retain(){++this._refCount}release(){if(--this._refCount,0===this._refCount)if(this._cache){const t=`${this._texture.descriptor.width} ${this._texture.descriptor.pixelFormat}`;this._cache.put(t,this)}else this.dispose()}dispose(){this._texture.dispose()}get texture(){return this._texture}generateMipmap(){this._texture.generateMipmap()}get descriptor(){return this._texture.descriptor}get usedMemory(){return this._texture.usedMemory}}export{t as default};
5
+ class t{constructor(t,e){this._texture=t,this._cache=e,this.type="tile-texture",this._refCount=1}retain(){++this._refCount}release(){if(--this._refCount,0===this._refCount)if(this._cache){const t=`${this._texture.descriptor.width} ${this._texture.descriptor.pixelFormat}`;this._cache.put(t,this)}else this.dispose()}dispose(){this._texture.dispose()}get texture(){return this._texture}generateMipmap(){this._texture.generateMipmap()}get descriptor(){return this._texture.descriptor}get cachedMemory(){return this._texture.usedMemory}}export{t as default};