// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("require ../../../chunks/tslib.es6 ../../../Color ../../../core/Accessor ../../../core/arrayUtils ../../../core/CollectionFlattener ../../../core/Evented ../../../core/has ../../../core/Logger ../../../core/mathUtils ../../../core/maybe ../../../core/MemCachePool ../../../core/ObjectPool ../../../core/PooledArray ../../../core/promiseUtils ../../../core/reactiveUtils ../../../core/accessorSupport/decorators/property ../../../core/accessorSupport/decorators/subclass ../../../core/libs/gl-matrix-2/math/mat4 ../../../core/libs/gl-matrix-2/factories/mat4f64 ../../../chunks/vec32 ../../../core/libs/gl-matrix-2/factories/vec3f64 ../../../core/support/UpdatingHandles ../../../geometry/ellipsoidUtils ../../../geometry/SpatialReference ../../../geometry/projection/projectors ../../../geometry/projection/projectPointToVector ../../../geometry/projection/projectVectorToVector ../../../geometry/support/aaBoundingRect ../../../geometry/support/frustum ../../../geometry/support/spatialReferenceUtils ../../../chunks/sphere ../../../layers/support/ElevationQueryTileCache ../../../layers/support/layerUtils ../../2d/engine/vectorTiles/VectorTile ../support/debugFlags ../support/ElevationRange ../support/ElevationUpdateEvent ../support/extentUtils ../support/index ../support/updatingProperties ./ElevationBounds ./ElevationData ./ExtentHelper ./interfaces ./LayerClass ./OverlayManager ./PlanarPatch ./RenderOrder ./ScaleRangeQueries ./SphericalPatch ./SplitLimits ./TerrainConst ./TerrainRenderer ./TerrainSurfacePerformanceInfo ./terrainUtils ./Tile ./TilePerLayerInfo ./TileUpdate ./tileUtils ./TilingSchemeLogic ./UpsampleInfo ../webgl-engine/core/shaderLibrary/output/BlendOptions ../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl ../webgl-engine/lib/basicInterfaces ../../support/RenderState ../../support/Scheduler ../../support/Yield".split(" "), function(la,m,ma,l,na,oa,pa,Ta,C,qa,A,ra,U,V,E,q,n,sa,ta,ua,W,O,va,wa,X,P,Y,xa,x,I,ya,J,za,Aa,Ba,Z,aa,Ca,Da,ba,Ea,K,ca,Fa,B,u,Ga,Ha,Ia,Ja,Ka,La,t,F,Ma,k,L,Na,p,D,Oa,Pa,da,ea,fa,ha,Q,Qa){function ia(a,b,c){for(const e of a)if(e.containsPointXY(b,c)){for(a=e;a&&!a.renderData;)a=a.children[(b>a.extentMidX?1:0)+(c{b&&ja(c); var e=0===c.maxLevelDeltaNeighborCount&&0===c.unmergableChildCount;c.maxLevelDeltaNeighborCount++;if(e)for(c=c.parent;c;)if(e=0===c.maxLevelDeltaNeighborCount&&0===c.unmergableChildCount,c.unmergableChildCount++,e)c=c.parent;else break})}function ja(a){if(!a.hasPendingUpdate(p.TileUpdate.SPLIT)){for(var b=a.parent;b?.resetPendingUpdate(p.TileUpdate.MERGE);)b=b.parent;a.resetPendingUpdate(p.TileUpdate.MERGE);a.isLeaf&&a.setPendingUpdate(p.TileUpdate.SPLIT);a.level{ja(c)})}}function ka(a){a.level{b.maxLevelDeltaNeighborCount--;if(0===b.maxLevelDeltaNeighborCount&&0===b.unmergableChildCount)for(b=b.parent;b;)if(b.unmergableChildCount--,0===b.maxLevelDeltaNeighborCount&&0===b.unmergableChildCount)b=b.parent;else break})}function S(a,b){if(!(a.level>t.maxTileNeighborLevelDelta,d=a.lij[2]>>t.maxTileNeighborLevelDelta,f=g=>g.isLeaf||g.level=== c;for(let g=0;4>g;++g){const h=a.findNeighborTile(k.neighborEdgeIndices[g],f);if(!h||h.level!==c)continue;const r=h.lij;r[1]===e&&r[2]===d||b(h)}}}var M;l=M=class extends pa.EventedMixin(l){constructor(a){super(a);this._scaleRangeQueries=new Ja.ScaleRangeQueries;this._iteratorPool=new U(D.IteratorPreorder,b=>b.remove=()=>this._iteratorPool.release(b));this._postorderIterator=new D.IteratorPostorder;this._hasPendingUpdates=!1;this._asyncWorkItems=this._pendingUpdates=0;this._allTilesSorted=this._allTilesDirty= !0;this._usedMemory=null;this._performanceInfo=new Ma;this._viewChanged=!1;this.heading=0;this._viewChangeUpdateDirty=this._inFrameTask=!1;this._eyePosRenderSR=O.create();this._eyePosSurfaceSR=O.create();this._splitLimits=new La.SplitLimits;this._frustum=I.create();this._viewProjectionMatrix=ua.create();this._layerViews=[[],[]];this._layerIndexByUid=[new Map,new Map];this._basemapLayerViewHandles=new Map;this._watchUpdatingTracking=new va.UpdatingHandles;this._frameTask=Q.ImmediateTask;this._allTiles= new V;this._upsampleInfoPool=new U(Pa.UpsampleInfo);this._shouldEmitChangeEvent=!1;this._rootTilesExtent=x.create();this.updatingProgress=.5;this._maxNumUpdating=1;this.maxTextureScale=1.2;this._spatialReference=X.WebMercator;this._elevationProjectorCache=new Map;this.visibleElevationBounds=new K.ElevationBounds(Infinity,-Infinity);this.rootTileElevationBounds=new K.ElevationBounds(Infinity,-Infinity);this._sebProjectorMap=new Map;this._sebProjectorCache=P.createEmptyProjectorCache();this._tilingSchemeSpatialReference= null;this._updatingRootTiles=!1;this._pendingTilesForElevationUpdateEvent=new Set;this._pendingTilesToUpdate=new Set;this.totalTileUpdates=this.totalGeometryUpdates=0;this._oneBatchPerFrameTask=!0;this._layerViewsDirty=!1;this.unloadedMemory=0;this._isWebMercatorOnPlateCarree=this._isWebMercator=this.ignoresMemoryFactor=!1;this.overlayManager=new Ga.OverlayManager({...a,surface:this});this._isGlobal=!a.view?.state?.isLocal;this._isGeographic=this._spatialReference?.isGeographic??!1;this._tileConstructor= this._isGlobal?Ka.SphericalPatch:Ha.PlanarPatch}initialize(){const a=this.view,b=a.resourceController,c=b.memoryController;this._tileCache=new ra.MemCachePool((g,h)=>c.newCache(g,h),"terrain-tile");this._upsampleMapCache=c.newCache("terrain-upsample",g=>g.unloadMapData());this._elevationQueryCache=new za.ElevationQueryTileCache(c.newCache("elevation-query"));const e=this.overlayManager;this._renderer=new F.TerrainRenderer(e.renderer,a._stage,this._allTiles,wa.getReferenceEllipsoid(a.spatialReference).radius, c);this.addHandles([q.watch(()=>e.renderer.isEmpty,()=>this._evaluateTransparency()),q.watch(()=>this.renderer.visible,g=>this.suspended=!g),q.watch(()=>this.heading,g=>{this._renderer.updateHeading(g);this._updateTileTextures(B.TextureUpdate.FADING)}),q.watch(()=>({heading:a.camera?.heading,state:a.state?.mode}),({heading:g,state:h})=>{if(null!=g)if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)this.heading=90*Math.round(g/90)%360;else{g=Math.round(g)%360;var r=Math.abs(g-this.heading); if(h===ha.RenderState.IDLE||30<=Math.min(r,360-r))this.heading=g}})],"overlayManager");this.addHandles([q.watch(()=>this.baseOpacity,()=>{this._handleLayerViewChanges();this._updateTileTextures(this._evaluateTransparency()?B.TextureUpdate.UNFADED:B.TextureUpdate.IMMEDIATE)},q.syncAndInitial),q.watch(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?B.TextureUpdate.UNFADED:B.TextureUpdate.IMMEDIATE),q.syncAndInitial),q.watch(()=>this.backgroundColor,(g,h)=>{g?.equals(h)|| (this._handleLayerViewChanges(),this._renderer.updateTileBackground(g))},q.sync),q.watch(()=>this.snapLevel,()=>this._viewChanged=!0,q.sync),q.watch(()=>this.view.pointsOfInterest,g=>{this._renderer.pointsOfInterest=g;this._watchUpdatingTracking.removeAll();g&&this._watchUpdatingTracking.add(()=>g.focus.renderLocation,()=>this._allTilesSorted=!1)}),q.watch(()=>Z.debugFlags.TERRAIN_TILE_TREE_SHOW_TILES,g=>{g&&!this._treeDebugger?(new Promise((h,r)=>la(["../layers/support/TerrainTileTree3DDebugger"], h,r))).then(({TerrainTileTree3DDebugger:h})=>{!this._treeDebugger&&Z.debugFlags.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new h({view:a}))}):g||(this._treeDebugger=A.destroyMaybe(this._treeDebugger))},q.initial)]);var {spatialReference:d}=a;this._extentHelper=Fa.create(this.viewingMode,{layers:a.map.allLayers,layerViews:a.allLayerViews,viewSpatialReference:d});const f=new oa({getCollections:()=>a.defaultsFromMap?.mapCollections?.map(({layers:g})=>g),getChildrenFunction:g=>g&&"layers"in g? g.layers:null});d=new Oa.TilingSchemeLogic({layers:f,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:d});this._set("tilingSchemeLogic",d);this._updateTilingScheme();this._elevationDataRequester=b.createStreamDataRequester(ba.ClientType.ELEVATION);this._mapDataRequester=b.createStreamDataRequester(ba.ClientType.BASEMAP);this._frameTask=b.scheduler.registerTask(Q.TaskPriority.TERRAIN_SURFACE,this);this.addHandles([q.watch(()=>this._extentHelper.stencilEnabledExtents, g=>this._renderer.setStencilEnabledLayerExtents(g),q.initial),q.watch(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),q.sync),q.watch(()=>this.extent,()=>this._updateRootTiles(),q.initial),a.on("resize",()=>this._viewChangeUpdate()),q.watch(()=>{const g=a.state;return[this._lodBias,this.lodSnapping,a.quality,g.camera,g.contentCamera,g.fixedContentCamera]},()=>this._viewChangeUpdate(),q.syncAndInitial),q.watch(()=>a.qualitySettings?.fadeDuration,g=>this._renderer.textureFadingEnabled= 0a.qualitySettings?.physicallyBasedRenderingEnabled,g=>this._renderer.pbrMode=g?ea.PBRMode.Simplified:ea.PBRMode.Disabled,q.initial),q.watch(()=>a.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),q.watch(()=>this._userClippingExtent,()=>this._updateClippingExtent(),q.sync)]);this.addHandles(a.allLayerViews.on("after-changes",()=>this._layerViewsDirty=!0));this._layerViewsDirty=!0;this._handleLayerViewChanges();this._renderer.updateTileBackground(this.backgroundColor)}destroy(){this._frameTask.remove(); this._watchUpdatingTracking.destroy();this._removeAllTiles();this._set("tilingSchemeLogic",A.destroyMaybe(this.tilingSchemeLogic));this._basemapLayerViewHandles.forEach((a,b)=>this._unregisterTiledLayerView(b));this._mapDataRequester=this._elevationDataRequester=null;this._set("overlayManager",A.destroyMaybe(this.overlayManager));this._tileCache=A.destroyMaybe(this._tileCache);L.Tile.prune();this._treeDebugger=A.destroyMaybe(this._treeDebugger);this._renderer=A.destroyMaybe(this._renderer);this._iteratorPool= A.destroyMaybe(this._iteratorPool);this._upsampleMapCache=A.destroyMaybe(this._upsampleMapCache);this._elevationQueryCache=A.destroyMaybe(this._elevationQueryCache);this._set("view",null);this._extentHelper=A.destroyMaybe(this._extentHelper);this._upsampleInfoPool=A.destroyMaybe(this._upsampleInfoPool);Ba.printAllocations();Na.printAllocations()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===B.LODSnapping.ON){var a=this.view,b=this.tilingScheme; const c=a.terrainScale;if(b&&c)return a=b.levelAtScale(c)+a.qualitySettings.tiledSurface.lodBias,b=b.getMaxLod(),Math.min(a,b||Infinity)}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?B.LODSnapping.ON:B.LODSnapping.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get _userClippingExtent(){var {spatialReference:a}=this,{clippingArea:b}= this.view;if(null==b||null==a)return null;const c=x.create();a=Da.toBoundingRect(b,c,a)?c:null;b=this._get("extent");return x.equals(a,b)?b:a}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const a=x.intersection(this.groundExtent,this._userClippingExtent,x.create()),b=this._get("extent");return x.equals(a,b)?b:a}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){this._hasPendingUpdates|| (this._maxNumUpdating=1);return!!((this.running||this._watchUpdatingTracking?.updating||0a?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}getElevation(a,b,c,e){const d=this._rootTiles;if(!d?.length||0===d[0].layerInfo[u.LayerClass.ELEVATION].length)return null;let f=this._elevationProjectorCache.get(e);void 0===f&&(f=P.getProjector(e,this._spatialReference)??null,this._elevationProjectorCache.set(e,f));if(null==f)return C.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"), null;a=W.set(H,a,b,c);f(a,0,a,0);return ia(d,a[0],a[1])}getElevations(a,b,c){const e=this._rootTiles;var d=e?e[0].layerInfo[u.LayerClass.ELEVATION].length:0;if(e?.length&&0!==d)for(d=0;da[2]&&(c+=1);H[1]{if(d&&x.intersectsSphere(d.extent,G)){const f=d.children;if(f[0]&&!d.rendered)for(const g of f)e(g);else d=this._getLodBiasCorrectedScale(d.level),c=null==c?d:Math.min(c,d)}};a=this._rootTiles;if(null!=a)for(const d of a)e(d);return c}queryVisibleScaleRange(a, b,c,e){b=b?this.tilingScheme.levelAtScale(b):0;c=c?this.tilingScheme.levelAtScale(c):Infinity;const d=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(a,b+d,c+d,e)}_evaluateTransparency(){var a=this.baseOpacity;const b=this.overlayManager.renderer.isEmpty;var c=this._renderer.transparency;a=this._allSurfaceLayersTransparent()?b?F.TransparencyMode.Empty:F.TransparencyMode.TransparentWithDraped:1<=a&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?F.TransparencyMode.Opaque: F.TransparencyMode.Semitransparent;if(c=c!==a)this._renderer.transparency=a,this.view?._stage?.renderer.setParameters({terrainTransparency:this._renderer.transparency});return c}_updateTilingScheme(){const a=this.tilingSchemeLogic.tilingScheme;if(a!==this.tilingScheme){k.weakAssert(!!a,"tiling scheme cannot be reset to undefined");this._isGlobal=!this.view?.state?.isLocal;this.tilingScheme&&this._removeAllTiles();var b=a?.spatialReference??X.WebMercator;this._spatialReference=b;this._isWebMercatorOnPlateCarree= (this._isWebMercator=!!b?.isWebMercator)&&ya.isPlateCarree(this.view?.renderSpatialReference);this._isGeographic=b?.isGeographic??!1;this._set("tilingScheme",a);this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference;this._sebProjectorMap.clear();this._updateClippingExtent();a&&(this._updateTiledLayers(),this._renderer.setTileSize(a.pixelSize),this.overlayManager.setSpatialReference(a.spatialReference),this._updateRootTiles())}}_acquireTile(a,b,c,e){const d=this._tileCache.pop(M._tileMemcacheKey); return d?(d.init(a,b,c,e,this),d):new this._tileConstructor(a,b,c,e,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const {extent:a,tilingScheme:b}=this;if(b){var c=Ra,e=b.rootTilesInExtent(a,c,5*t.maxRootTiles);if(null!=this._rootTiles){if(e.length>t.maxRootTiles){C.getLogger(this).warn(t.tooManyRootTilesAfterChangeError);return}const d=this._rootTiles.map(g=>g.lij),f=na.difference(d,e,L.lijEquals);this._updatingRootTiles=!0;if(0-1L.lijEquals(r,h.lij))?(this._purgeTile(h),!1):!0);f.added.forEach(h=>g.push(this._newRootTile(h)));this._setRootTiles(g)}}else this._updatingRootTiles=!0,e.length>t.maxRootTiles&&(C.getLogger(this).warn(t.tooManyRootTilesForLayerError),e=b.rootTilesInExtent(a,c,t.maxRootTiles)),this._setRootTiles(e.map(d=>this._newRootTile(d)));x.equals(c,this._rootTilesExtent)||(this._rootTilesExtent=x.create(c));this.renderer.visible=!0;this._viewChangeUpdate(); this.overlayManager.setPlacementDirty();this.notifyChange("ready");this._updateAllTileGeometries();this._updatingRootTiles=!1;this.checkAllTilesWaterproofness()}}_updateAllTileGeometries(){const a=this._allTiles.filter(b=>b.isLoaded&&b.intersectsClippingArea);a.sort(D.compareTilesByLij);a.forEach(b=>this._renderer.updateTileGeometryState(b));a.forEach(b=>b.renderData.updateNeighborData());this._updateTilesGeometries(a);this._pendingTilesToUpdate.clear()}_updateTilesGeometries(a){if(0!==a.length){a.sort(D.compareTilesByLij); var b=this.renderer;a.forEach(c=>b.updateGeometryIfNeeded(c));a.forEach(c=>this._pendingTilesForElevationUpdateEvent.add(c))}}_shouldSplit(a){return a.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===p.TileUpdate.SPLIT}_newRootTile(a){a=this._acquireTile(0,a[1],a[2],null);this._shouldSplit(a)&&a.setPendingUpdate(p.TileUpdate.SPLIT);this._loadTile(a);this._markTileToUpdate(a);this._updateRootTileElevationBounds();return a}_setRootTiles(a){this._rootTiles=a;this._allTiles.clear(); if(null!=a){const b=this._iteratorPool.acquire();for(b.reset(a);!b.done;)this._allTiles.push(b.next());b.remove()}this._renderer.setRootTiles(this._rootTiles);this._updateTilesVisibility(a)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(), this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(a){a.updateClippingStatus(this.extent)&&a.resetPendingUpdate(p.TileUpdate.GEOMETRY)&&this._updateTileGeometryState(a)}_updateTilesVisibility(a){if(null!=a){var b=D.hasLoadableSiblings(a),c=this.visibleElevationBounds,e=b?c.min:Infinity;b=b?c.max:-Infinity;var d=this.extent,f=this._viewProjectionMatrix;this.setTileTreeDirty();var g=this._iteratorPool.acquire();for(g.reset(a);!g.done;)a=g.next(),a.updateClippingStatus(d)&&a.resetPendingUpdate(p.TileUpdate.GEOMETRY)&& this._updateTileGeometryState(a),a.computeVisibility(),a.updateScreenDepth(f),a.renderData&&(e=Math.min(a.elevationBoundsMin,e),b=Math.max(a.elevationBoundsMax,b));g.remove();this._allTilesDirty=this._viewChanged=!0;this._updatePendingTileGeometries();isFinite(e)&&isFinite(b)&&(c.min!==e||c.max!==b)&&(this.visibleElevationBounds=new K.ElevationBounds(e,b))}}_updateRootTileElevationBounds(){let a=Infinity,b=-Infinity;var c=this._rootTiles;null!=c&&c.forEach(({elevationBoundsMin:e,elevationBoundsMax:d})=> {a=Math.min(a,e);b=Math.max(b,d)});c=this.rootTileElevationBounds;if(c.min!==a||c.max!==b)this.rootTileElevationBounds=new K.ElevationBounds(a,b)}_updateViewDependentParameters(){const {camera:a,contentCamera:b}=this.view.state,c=Math.tan(.5*b.fovX),e=Math.tan(.5*b.fovY),d=this.tilingScheme.pixelSize,f=2**-this._lodBias*a.pixelRatio;this._splitLimits.aboveGround=a.aboveGround;this._splitLimits.fovX=c;this._splitLimits.fovY=e;this._splitLimits.relativeWidthLimit=d/a.width*this.maxTextureScale*f;this._splitLimits.relativeHeightLimit= d/a.height*this.maxTextureScale*f;this._splitLimits.maxLod=this.tilingScheme.getMaxLod();this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias;this._splitLimits.frustum=this.view.state.fixedContentCamera?I.copy(this._splitLimits.frustum??I.create(),b.frustum):null;I.copy(this._frustum,a.frustum);ta.multiply(this._viewProjectionMatrix,b.projectionMatrix,b.viewMatrix);W.copy(this._eyePosRenderSR,b.eye);xa.projectVectorToVector(a.eye,this.view.renderSpatialReference, this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(a){a.updateVisibility();this._renderer.updateTileGeometryState(a)&&this._markTileToUpdate(a);this._usedMemory=null}_markAllTileNeighborsForUpdate(a){a.forEachLoadedNeighbor(b=>{this._layerViews[u.LayerClass.MAP].some(k.isVectorTileLayerView)&&b.setPendingUpdate(p.TileUpdate.TEXTURE_FADING);this._pendingTilesToUpdate.add(b)})}_updateTileTexture(a,b){const c=a.resetPendingUpdate(p.TileUpdate.TEXTURE_FADING)?p.TileUpdate.TEXTURE_FADING: a.resetPendingUpdate(p.TileUpdate.TEXTURE_NOFADING)?p.TileUpdate.TEXTURE_NOFADING:!1;c&&(this._renderer.updateTileTexture(a,c),this._usedMemory=null,b.madeProgress())}_emitElevationUpdateEventForTiles(){if(this._shouldEmitChangeEvent){var a=T.extent;x.empty(a);this._pendingTilesForElevationUpdateEvent.forEach(b=>x.expand(a,b.extent,a));this._pendingTilesForElevationUpdateEvent.clear();T.spatialReference=this.spatialReference;this.emit("elevation-change",T);this._shouldEmitChangeEvent=!1}}runTask(a){this._handleLayerViewChanges(a); this._frameTask.processQueue(a);this.renderer.processScaleRangeQueries(this._scaleRangeQueries,a);this._inFrameTask=!0;this._pendingUpdates=0;this._hasPendingUpdates=!1;this._updateAllTilesStatus(a);this._sortTiles(a);const b=!this.view.state.fixedContentCamera;this._mergeAndSplit(a,b);this._updateElevation(a);this._updateTextures(a);b||this._mergeAndSplit(a,!0);this._inFrameTask=!1;this._runViewChangeUpdateIfDirty();this._updatePendingTileGeometries();this._emitElevationUpdateEventForTiles();a.done&& a.hasProgressed&&this.requestUpdate();this.notifyChange("updatingProgressValue");k.enableTerrainInternalChecks&&this._checkTileInvariant();if(!a.hasProgressed)return Qa.Yield}_checkTileInvariant(){const a=new Map;this._allTiles.forAll(b=>a.set(b,new Set));this._allTiles.forAll(b=>{k.weakAssert(b.rendered===b.isLeaf,` rendered ${b.rendered} != ${b.isLeaf} leaf`);if(!b.isLeaf){var c=b.children.reduce((f,g)=>f+(0===g.unmergableChildCount&&0===g.maxLevelDeltaNeighborCount?0:1),0);k.weakAssert(b.unmergableChildCount=== c,` Tile[${b.lij.toString()}] unmergeable child count mismatch:`+` actual ${b.unmergableChildCount} vs ${c}`);if(b.hasPendingUpdate(p.TileUpdate.MERGE)){k.weakAssert(!b.hasPendingUpdate(p.TileUpdate.SPLIT),"Tile can be both split and merge at the same time");for(var e of b.children)k.weakAssert(e.isLeaf||e.hasPendingUpdate(p.TileUpdate.MERGE),"Child of tile to merge must also merge")}}for(c=0;4>c;++c){if(b.rendered&&(e=b.renderData?.geometryState.edgePeerNeighbors[c],null!=e)){var d=b.level-e.level<= t.maxTileNeighborLevelDelta;d||(console.log(`tile level delta [${b.lij.toString()}] vs [${e.lij.toString()}] > ${t.maxTileNeighborLevelDelta} (edge[${c}])`),k.weakAssert(d,`tile level delta [${b.level}] vs [${e.level}] > ${t.maxTileNeighborLevelDelta}`));k.weakAssert(b.level-e.level<=t.maxTileNeighborLevelDelta,`Max tile lod delta exceeded: [${b.lij.toString()}] vs [${e.lij.toString()}]`)}d=b.level-t.maxTileNeighborLevelDelta;e=b.findNeighborTile(k.neighborEdgeIndices[c],f=>f.isLeaf||f.level===b.level); if(null!=e){if(b.isLeaf&&b.level>=t.maxTileNeighborLevelDelta){let f=e;for(;b.level-f.level>t.maxTileNeighborLevelDelta,b.lij[2]>>t.maxTileNeighborLevelDelta],f.lij)||(d=a.get(f),k.weakAssert(!d.has(b),"Cannot already have neighbor"),d.add(b))}k.weakAssert(e.rendered||e.level===b.level,"Non-same-level-neighbor of rendered must be rendered");k.weakAssert(b.level-e.level<=t.maxTileNeighborLevelDelta,`Tile level delta [${b.level}] vs [${e.level}] > ${t.maxTileNeighborLevelDelta}`)}}}); this._allTiles.forAll(b=>{const c=b.maxLevelDeltaNeighborCount,e=a.get(b);k.weakAssert(c===e.size,`Tile[${b.lij.toString()}] merge-blocker mismatch: actual ${c} vs ${e.size}`)})}_updateAllTilesStatus(a){if(this._viewChanged&&this._rootTiles&&!a.done){this._viewChanged=!1;var b=new Sa(this._allTiles.length);b.pushAll(this._rootTiles);var c=this.snapLevel,e=this._splitLimits,d=this._eyePosRenderSR;this._allTiles.forAll(h=>{h.maxLevelDeltaNeighborCount=0;h.unmergableChildCount=0});for(var f=this._viewProjectionMatrix;!b.empty;){const h= b.pop();var g=h.parent;const r=(g=null!=g&&g.hasPendingUpdate(p.TileUpdate.MERGE))?p.TileUpdate.MERGE:h.shouldSplit(e,d,c),v=r===p.TileUpdate.SPLIT;h.isLeaf?R(h,v):b.pushAll(h.children);g?(h.resetPendingUpdate(p.TileUpdate.SPLIT),h.isLeaf||h.setPendingUpdate(p.TileUpdate.MERGE),this._updateClippingStatus(h),h.updateVisibility(),h.updateScreenDepth(f)):v?(h.resetPendingUpdate(p.TileUpdate.MERGE),h.isLeaf&&h.setPendingUpdate(p.TileUpdate.SPLIT)):(h.resetPendingUpdate(p.TileUpdate.SPLIT)&&h.updateAgentSuspension(), r===p.TileUpdate.ELEVATION&&h.updateAgents(u.LayerClass.ELEVATION),h.isLeaf||(h.setPendingUpdate(p.TileUpdate.MERGE),h.resetPendingUpdate(p.TileUpdate.SPLIT)))}this.requestUpdate();!this._shortBatches&&this._oneBatchPerFrameTask||this._updatePendingTileGeometries();a.madeProgress()}}_sortTiles(a){a.done||this._allTilesSorted||(D.sortTilesByPOI(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),a.madeProgress())}_markTileToUpdate(a){k.internalAssert(a.isLoaded); a.intersectsClippingArea&&(this._pendingTilesToUpdate.add(a),this._markAllTileNeighborsForUpdate(a))}_updatePendingTileGeometries(){const a=this._pendingTilesToUpdate,b=Array.from(a.keys()).filter(d=>d.isLoaded&&d.intersectsClippingArea);if(0===b.length)a.clear();else{var c=(d,f)=>{!f?.isLoaded||!f.intersectsClippingArea||f.level{const y=k.neighborCornerIndices[w];c(f,r.cornerPeerNeighbors[w]?.findCorner(k.oppositeCorner(y),z=>z.isLoaded))};for(let w=0;4>w;++w)if(h&1<=f.level&&y.forAllSubtreeOnSide(k.oppositeEdge(k.neighborEdgeIndices[w]),z=>z.isLoaded&&z.intersectsClippingArea?(k.internalAssert(a.has(z)||0>D.compareTilesByLij(f, z)),c(f,z),!0):!1);v((w+1)%4);v(w)}}a.clear();this._updateTilesGeometries(b);this._shouldEmitChangeEvent=!0;k.enableTerrainInternalChecks&&k.enableWaterproofTests&&this.checkAllTilesWaterproofness()}}_mergeAndSplit(a,b){if(!this.suspended&&!a.done&&this._allTilesDirty){this._allTilesDirty=!1;this.requestUpdate();for(var c=!1,e=this.view.state.fixedContentCamera,d=!1;!a.done;){d=!0;let f=!1;const g=!this._allTiles.some(h=>{if(!c&&!e&&!h.visible)return a.done;var r=h;if(h.hasPendingUpdate(p.TileUpdate.MERGE)){if(!b|| 0=t.maxTileNeighborLevelDelta){const w=y=>y.isLeaf||v-y.levely;++y){const z=h.findNeighborTile(k.neighborEdgeIndices[y],w);null!=z&&v-z.level===t.maxTileNeighborLevelDelta&& (r=!1,k.enableTerrainInternalChecks&&(k.internalAssert(z.isLeaf),k.internalAssert(z.hasPendingUpdate(p.TileUpdate.SPLIT))))}}r?(this._splitTile(h),a.madeProgress(),f=!0):h.setPendingUpdate(p.TileUpdate.SPLIT)}return a.done});f&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries());if(g)if(!c)c=!0;else{if(!f)break}else this._allTilesDirty=!0}d?a.madeProgress():this._allTilesDirty=!0;!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(); this._sortTiles(a)}}_updateElevation(a){a.done||(this._allTiles.some(b=>{b.resetPendingUpdate(p.TileUpdate.GEOMETRY)&&(this._updateTileGeometryState(b),this._shortBatches&&this._updatePendingTileGeometries(),a.madeProgress());return a.done}),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(a){a.done||this._allTiles.some(b=>{this._updateTileTexture(b,a);return a.done})}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(fa.RenderRequestType.UPDATE), this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){return this.view.qualitySettings.tiledSurface.lodBias-(1-this.view.quality)*t.maxMemoryLodBias}_getLodBiasCorrectedScale(a){const b=this.tilingScheme.levels;a=qa.clamp(a-this._lodBias,0,b.length-1);const c=a-Math.floor(a);return b[Math.floor(a)].scale*(1-c)+b[Math.ceil(a)].scale*c}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach(a=>this._purgeTile(a)),this._setRootTiles(null),this.notifyChange("ready")); this._allTiles.clear();this.renderer.visible=!1}_purgeDescendantTiles(a){if(a.children[0]){var b=a.children.slice();a.unsetChildren();for(a=0;4>a;++a)this._purgeTile(b[a])}}_purgeTile(a){a.isLeaf?ka(a):this._purgeDescendantTiles(a);this._allTiles.removeUnordered(a);this._unloadTile(a);this._tileCache.put(M._tileMemcacheKey,a)}_unloadTile(a){this._pendingTilesToUpdate.delete(a);this._pendingTilesForElevationUpdateEvent.delete(a);a.unload(this._renderer)}_splitTile(a){k.weakAssert(a.isLeaf,"Tile that is already split should not be split again!"); k.weakAssert(a.rendered,"Tile marked to split is not rendered");ka(a);var b=a.level+1;const c=2*a.lij[1],e=2*a.lij[2];b=a.setChildren(this._createTile(b,c,e,a),this._createTile(b,c,e+1,a),this._createTile(b,c+1,e,a),this._createTile(b,c+1,e+1,a));this._allTiles.pushArray(b);a.updateAgentSuspension();k.weakAssert(a.rendered,"parent should be rendered");this._unloadTile(a);b.forEach(d=>this._loadTile(d));b.forEach(d=>this._pendingTilesToUpdate.add(d));this._markAllTileNeighborsForUpdate(a);this._emitTileScaleChange(a, a.level+1);this._allTilesDirty=!0;this._shortBatches&&this._updatePendingTileGeometries();b.forEach(d=>R(d,d.hasPendingUpdate(p.TileUpdate.SPLIT)));++this._performanceInfo.numSplit}_emitTileScaleChange(a,b=a.level){N.spatialReference=this.spatialReference;N.extent=a.extent;N.scale=this._getLodBiasCorrectedScale(b);this.emit("scale-change",N)}_createTile(a,b,c,e){k.weakAssert(!!e,"_createTile sanity check");a=this._acquireTile(a,b,c,e);a.updateClippingStatus(this.extent);a.updateScreenDepth(this._viewProjectionMatrix); this._shouldSplit(a)&&a.setPendingUpdate(p.TileUpdate.SPLIT);return a}get _shortBatches(){return this.view.state.mode!==ha.RenderState.IDLE}_mergeTile(a){k.weakAssert(!a.hasPendingUpdate(p.TileUpdate.SPLIT),"_mergeTile sanity check");k.weakAssert(!a.isLeaf,"Cannot merge a leaf");a.isLeaf||(this._purgeDescendantTiles(a),k.weakAssert(!a.renderData,"_mergeTile sanity check"),this._loadTile(a),this._markTileToUpdate(a),this._emitTileScaleChange(a),this._shortBatches&&this._updatePendingTileGeometries(), R(a,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(a){a.load();this.requestUpdate();this._allTilesDirty=!0;this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(a)}_handleLayerViewChanges(a=Q.noBudget){if(this._layerViewsDirty){var b=this._layerViewsDirty=!1,c=new Set,e=-1;for(let f=this.view.allLayerViews.length-1;0<=f;f--){var d=this.view.allLayerViews.items[f];c.add(d.uid);if(k.isSurfaceLayerView(d)||k.isGroupLayerView(d))if(this._basemapLayerViewHandles.has(d.uid)&& !k.isGroupLayerView(d)){const g=this._layerClassFromLayerView(d);d=this._getLayerIdxByUID(g,d.uid);if(null!=d){if(d{c.has(g)||(this._unregisterTiledLayerView(g),b=!0)});b&&this._updateTiledLayers();this.hasCompositeBlendMode=this._hasCompositeBlendMode();this._evaluateTransparency();a.madeProgress()}}_allSurfaceLayersTransparent(){let a=0===this.view.map?.ground?.opacity; for(const b of this.view.allLayerViews.items)if(k.isMapTileLayerView(b)&&!Aa.isBaseLayer(b.layer)&&0!==b.fullOpacity){a=!1;break}return a}_hasCompositeBlendMode(){for(const a of this.view.allLayerViews.items)if((k.isBlendableLayerView(a)||k.isGroupLayerView(a))&&da.isCompositeBlendMode(da.blendModeFromString[a.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(a){return k.isElevationLayerView(a)?u.LayerClass.ELEVATION:u.LayerClass.MAP}_registerTiledLayerView(a){const b=[];(k.isBlendableLayerView(a)|| k.isGroupLayerView(a))&&b.push(q.watch(()=>a.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode();this._updateTileTextures(B.TextureUpdate.UNFADED)}));if(!k.isGroupLayerView(a)){const c=this._layerClassFromLayerView(a);b.push(q.watch(()=>a.suspended,()=>this._updateTiledLayers()));b.push(q.watch(()=>a.fullOpacity,()=>this._updateTileTextures(B.TextureUpdate.UNFADED)));b.push(q.watch(()=>"effectiveScaleRange"in a.layer?a.layer.effectiveScaleRange:null,()=>this._restartAllAgents(c))); b.push(a.on("data-changed",()=>{const e=this._getLayerIdxByUID(c,a.uid);null!=e&&this._invalidateLayerData(e,c)}))}this._unregisterTiledLayerView(a.uid);this._basemapLayerViewHandles.set(a.uid,b)}_unregisterTiledLayerView(a){const b=this._basemapLayerViewHandles.get(a);if(b){for(const c of b)c.remove();this._basemapLayerViewHandles.delete(a)}}_updateTiledLayers(){if(this.tilingScheme&&!this.view.suspended){var a=[[],[]],b=null;this.view.allLayerViews.forEach(e=>{if(e.layer&&!e.suspended&&k.isSurfaceLayerView(e)&& e.fullExtent){var d=this._layerClassFromLayerView(e);if(d===u.LayerClass.MAP){const f=e.displayLevelRange.maxLevel;Infinity!==f&&(null===b||f>b)&&(b=f)}a[d].push(e)}});for(const e of u.LayerClasses){var c=this._layerViews[e];const d=a[e];d.reverse();const f=d.length;let g=c.length!==f;const h=Array(f),r=Array(c.length);this._layerIndexByUid[e].clear();for(let v=0;v {b.updateAgents(u.LayerClass.MAP);a===B.TextureUpdate.IMMEDIATE?this.renderer.updateTileTexture(b,p.TileUpdate.TEXTURE_NOFADING):b.updateRenderData(u.LayerClass.MAP,a)});this._evaluateTransparency()}_invalidateLayerData(a,b){this._allTiles.forAll(c=>c.removeLayerAgent(a,b));this._allTiles.forAll(c=>c.invalidateLayerData(a,b))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(a=fa.RenderRequestType.UPDATE){this.renderer.setNeedsRender(a)}requestUpdate(){1===++this._pendingUpdates&&(this._hasPendingUpdates= !0)}requestTileData(a,b,c,e){const d=this.layerViewByIndex(b,c);b=d.layer;if(!b.tilemapCache||k.isVectorTileLayerView(d))return this._requestTileData(a,c,d,e);++this._asyncWorkItems;return b.tilemapCache.fetchAvailability(a.lij[0],a.lij[1],a.lij[2],{...e,timeout:6E3}).then(()=>--this._asyncWorkItems).catch(f=>{--this._asyncWorkItems;E.throwIfAborted(e);E.isAbortError(f)||this._dataMissing(a,c,d);throw f;}).then(()=>this._frameTask.schedule(()=>this._requestTileData(a,c,d,e),e.signal))}_requestTileData(a, b,c,e){b=b===u.LayerClass.ELEVATION;e.requester??(e.requester=b?this._elevationDataRequester:this._mapDataRequester);return b?k.isElevationLayerView(c)?this._requestElevationTileData(a,c,e):Promise.reject():k.isMapTileLayerView(c)?this._requestMapTileData(a,c,e):Promise.reject()}_requestElevationTileData(a,b,c){++this._asyncWorkItems;const e=d=>{!E.isAborted(c)&&d&&(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(a,b,d))};return b.fetchTile(a.lij,c).then(d=>this._frameTask.schedule(()=> e(d)),d=>{E.isAbortError(d)||(C.getLogger(this).error(`Tile ${a.lij.toString()} layer ${u.LayerClass.ELEVATION}/${b.uid} error ${d}`),this._dataMissing(a,u.LayerClass.ELEVATION,b),this.requestUpdate())}).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(a,b,c){b=this._layerIndexByUid[u.LayerClass.ELEVATION].get(b.uid);if(null==b)C.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",u.LayerClass.ELEVATION,a.lij.toString());else{c=new ca.ElevationData(a.lij,a.extent, c);a.dataArrived(b,u.LayerClass.ELEVATION,c);c=[a];a=a.level;var e=this._iteratorPool.acquire();for(e.reset(c);!e.done;){const d=e.next();d.findElevationBoundsForLayer(b,a);d.computeElevationBounds()}0===a&&this._updateRootTileElevationBounds();e.remove();this._updateTilesVisibility(c)}}_requestMapTileData(a,b,c){++this._asyncWorkItems;const e=(f,g)=>{k.releaseTerrainData(g);E.isAborted(c)||(console.error(`Tile ${a.lij.toString()} layer ${u.LayerClass.MAP}/${b.uid} error ${f}`),this._dataMissing(a, u.LayerClass.MAP,b),this.requestUpdate())},d=f=>g=>e(g,f);return b.fetchTile(a.lij,c).then(f=>this._frameTask.schedule(()=>{this.requestUpdate();E.isAborted(c)?k.releaseTerrainData(f):this._mapTileDataArrived(a,b,f)},c.signal,d(f)).catch(d(f)),(f,g=null)=>this._frameTask.schedule(()=>e(f,g))).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(a,b,c){b=this._getLayerIdxByUID(u.LayerClass.MAP,b.uid);null==b?(k.releaseTerrainData(c),C.getLogger(this).warn("TerrainSurface: received data from unknown layer")): a.dataArrived(b,u.LayerClass.MAP,c)}_getLayerIdxByUID(a,b){return this._layerIndexByUid[a].get(b)}_dataMissing(a,b,c){c=this._getLayerIdxByUID(b,c.uid);null!=c?a.dataMissing(c,b):C.getLogger(this).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(a){this._rootTiles&&this.overlayManager&&(this._allTiles.forAll(b=>{b.renderData&&this.overlayManager.setTileParameters(b)}),this._renderer.setNeedsRender(a))}get performanceInfo(){const a=this._performanceInfo;a.numNodes=this._allTiles.length; a.numLeaves=a.numVisible=a.numRendered=a.numLoadedPerLevel.length=a.numRenderedPerLevel.length=0;this._allTiles.forAll(b=>{b.isLeaf&&a.numLeaves++;const c=b.level;b.renderData&&(a.numLoadedPerLevel[c]=(a.numLoadedPerLevel[c]||0)+1);b.visible&&(a.numVisible++,b.rendered&&(a.numRenderedPerLevel[c]=(a.numRenderedPerLevel[c]||0)+1,a.numRendered++))});return a}get usedMemory(){if(!this.tilingScheme)return 0;null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory());return this._usedMemory?? 0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((a,b)=>a+b.usedMemory,0)):null}getUsedMemoryForLayerView(a){let b=0;const c=this._layerClassFromLayerView(a),e=this._getLayerIdxByUID(c,a.uid);null!=e&&this._allTiles.forAll(d=>b+=d.getUsedMemoryForLayer(c,e));return b}getTile(a){if(null==a||null==this._rootTiles)return null;const b=a.split("/").map(f=>+f);if(0===b[0])return this._rootTiles.find(f=>f.lij[1]===b[1]&&f.lij[2]===b[2]);a=b[0];const c=b[1]>>a,e=b[2]>> a;let d;this._rootTiles.some(f=>f.lij[1]===c&&f.lij[2]===e?(d=f,!0):!1);if(d){for(a=1<>=1}k.weakAssert(d.lij[0]===b[0]&&d.lij[1]===b[1]&&d.lij[2]===b[2],"not the right tile?");return d}return null}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(a){this._renderer.renderPatchBorders=a}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(a){this._renderer.visualizeNormals= a}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(a){this._renderer.renderingDisabled=a}get test(){}checkAllTilesWaterproofness(){if(k.enableWaterproofTests){var a=this._rootTiles;if(null!=a){var b=d=>0{if(d.intersectsClippingArea)if(d.renderData&&!d.renderData.geometryState&&console.error("Tile[",d.lij,"] has renderData but not geometryState"),d.renderData&&!d.renderData.geometry&&console.error("Tile[",d.lij,"] has renderData but not geometryInfo"), !d.renderData?.geometry||0<(d.renderData.geometry.indices?.length??0)||console.error("Tile[",d.lij,"] has renderData but no indices - geometryInfo: ",d.renderData.geometry),b(d)){d.checkGeometryWaterproofness();for(const h of d.children){var f=h,g=d;b(f)&&console.error("Tile[",f.lij,"] has geometry although parent[",g.lij,"] has geom")}}else if(d.isLeaf)console.error("Tile[",d.lij,"] has no geometry and no children, from root to leaf");else for(f of d.children)c(f)},e=d=>{const f=d.parent?.visible?? !0,g=d.visible;d.computeVisibility();const h=d.visible;g!==h&&f&&console.error(" Tile[",d.lij,"] has out of date visibility: ",g," instead of ",h);if(!d.isLeaf)for(const r of d.children)e(r)};for(const d of a)c(d),e(d)}}}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(a){return this._isGlobal&&a[2]===this.lijEastEnd(a[0])-1}isWestEndWrap(a){return this._isGlobal&& 0===a[2]}lijEastEnd(a){return 1<c?b:0))%b]:null}enableInternalChecks(a){k.enableInternalTerrainChecks(a)}enableWaterproofnessChecks(a){k.enableTerrainWaterproofChecks(a)}};l._tileMemcacheKey="TerrainTileMemcache";m.__decorate([n.property()],l.prototype,"_renderer",void 0);m.__decorate([n.property({constructOnly:!0})],l.prototype,"_scaleRangeQueries",void 0);m.__decorate([n.property({constructOnly:!0})], l.prototype,"view",void 0);m.__decorate([n.property({constructOnly:!0})],l.prototype,"overlayManager",void 0);m.__decorate([n.property()],l.prototype,"_hasPendingUpdates",void 0);m.__decorate([n.property()],l.prototype,"_asyncWorkItems",void 0);m.__decorate([n.property()],l.prototype,"_allTilesDirty",void 0);m.__decorate([n.property()],l.prototype,"_allTilesSorted",void 0);m.__decorate([n.property()],l.prototype,"_viewChanged",void 0);m.__decorate([n.property({type:Number})],l.prototype,"heading", void 0);m.__decorate([n.property()],l.prototype,"_splitLimits",void 0);m.__decorate([n.property({readOnly:!0})],l.prototype,"_watchUpdatingTracking",void 0);m.__decorate([n.property()],l.prototype,"_frameTask",void 0);m.__decorate([n.property({readOnly:!0})],l.prototype,"snapLevel",null);m.__decorate([n.property({readOnly:!0})],l.prototype,"lodSnapping",null);m.__decorate([n.property()],l.prototype,"_userClippingExtent",null);m.__decorate([n.property()],l.prototype,"_rootTilesExtent",void 0);m.__decorate([n.property({readOnly:!0})], l.prototype,"extent",null);m.__decorate([n.property({readOnly:!0})],l.prototype,"groundExtent",null);m.__decorate([n.property({readOnly:!0})],l.prototype,"_tilingSchemeExtent",null);m.__decorate([n.property({readOnly:!0})],l.prototype,"updating",null);m.__decorate([n.property({readOnly:!0})],l.prototype,"running",null);m.__decorate([n.property(Ea.updatingProgress)],l.prototype,"updatingProgress",void 0);m.__decorate([n.property({readOnly:!0})],l.prototype,"updatingProgressValue",null);m.__decorate([n.property()], l.prototype,"_maxNumUpdating",void 0);m.__decorate([n.property()],l.prototype,"baseOpacity",null);m.__decorate([n.property()],l.prototype,"hasCompositeBlendMode",void 0);m.__decorate([n.property({readOnly:!0})],l.prototype,"viewingMode",null);m.__decorate([n.property()],l.prototype,"maxTextureScale",void 0);m.__decorate([n.property({readOnly:!0})],l.prototype,"ready",null);m.__decorate([n.property({value:Ia.RenderOrder.FRONT_TO_BACK})],l.prototype,"renderOrder",null);m.__decorate([n.property({readOnly:!0})], l.prototype,"rootTiles",null);m.__decorate([n.property()],l.prototype,"_rootTiles",void 0);m.__decorate([n.property({readOnly:!0})],l.prototype,"spatialReference",null);m.__decorate([n.property({type:ma})],l.prototype,"backgroundColor",null);m.__decorate([n.property({value:!1})],l.prototype,"slicePlaneEnabled",null);m.__decorate([n.property({readOnly:!0})],l.prototype,"tilingScheme",void 0);m.__decorate([n.property({readOnly:!0})],l.prototype,"tilingSchemeLocked",null);m.__decorate([n.property({readOnly:!0})], l.prototype,"tilingSchemeLogic",void 0);m.__decorate([n.property()],l.prototype,"wireframe",null);m.__decorate([n.property({value:!1})],l.prototype,"suspended",null);m.__decorate([n.property()],l.prototype,"fadeDuration",null);m.__decorate([n.property()],l.prototype,"visibleElevationBounds",void 0);m.__decorate([n.property()],l.prototype,"rootTileElevationBounds",void 0);m.__decorate([n.property()],l.prototype,"_layerViewsDirty",void 0);m.__decorate([n.property()],l.prototype,"renderPatchBorders", null);m.__decorate([n.property()],l.prototype,"visualizeNormals",null);m.__decorate([n.property()],l.prototype,"renderingDisabled",null);m=l=M=m.__decorate([sa.subclass("esri.views.3d.terrain.TerrainSurface")],l);const H=O.create(),G=J.create(),Ra=x.create();new V;const T=new Ca.ElevationUpdateEvent("ground"),N={spatialReference:null,extent:null,scale:0};class Sa{constructor(a){this.capacity=a;this._tail=this._head=0;this._data=Array(a)}push(a){const b=this._tail;if(b=this._tail}get full(){return this._tail>=this._data.length}}return m});