/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{AttributeStoreView as e}from"./webgl/AttributeStoreView.js";import t from"./webgl/TileContainer.js";const i=60;class s extends t{constructor(t){super(t),this._statisticsByLevel=new Map,this._entityIndex=new Map,this.attributeView=new e}destroy(){super.destroy(),this.children.forEach(e=>e.destroy()),this.removeAllChildren(),this.attributeView.destroy()}doRender(e){e.context.capabilities.enable("textureFloatLinear"),super.doRender(e)}get hasAnimations(){for(const e of this.children)if(e.hasAnimations)return!0;return!1}_reindexAndUpdateFeaturesIfNeeded(){if(this.hasAnimations&&(this._reindexFeatures(),0!==this.attributeView.size))for(const e of this._entityIndex.values())e.dirty&&(this.attributeView.setData(e.displayId,7,0,e.firstIndexed),e.dirty=!1)}restartAnimation(e){const t=this._entityIndex.get(e);if(!t)return;const i=performance.now()/1e3;t.firstIndexed=i,t.dirty=!0}restartAllAnimations(){const e=performance.now()/1e3;for(const[t,i]of this._entityIndex)i.firstIndexed=e,i.dirty=!0}_reindexFeatures(){const e=performance.now()/1e3;for(const t of this.children)for(const i of t.entityIds){const{objectId:t}=i;let s=this._entityIndex.get(t);s||(s={objectId:t,displayId:0,firstIndexed:e,lastIndexed:0,dirty:!0},this._entityIndex.set(t,s)),s.lastIndexed=e,s.displayId=i.displayId}for(const[t,s]of this._entityIndex)e-s.lastIndexed>i&&this._entityIndex.delete(t)}_updateAttributeView(){this.attributeView.update()&&(this.requestRender(),this.hasLabels&&this.requestDeclutter()),this._reindexAndUpdateFeaturesIfNeeded()}createRenderParams(e){const t=super.createRenderParams(e);return t.attributeView=this.attributeView,t.instanceStore=this._instanceStore,t.statisticsByLevel=this._statisticsByLevel,t}}export{s as AFeatureContainer};
