// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define(["../../core/reactiveUtils","../../core/scheduling","./PaddedViewState"],function(f,g,h){class k{constructor(a){this.view=a;this._updateParameters=this._frameTaskHandle=this._stationaryHandle=null;this._updateRequested=!1;this.stationary=!0;this.animationInProgress=!1;this.prepare=()=>{this._updateParameters&&(this._updateParameters.state=this.view.state,this._updateParameters.stationary=this.view.stationary,this._updateParameters.pixelRatio=window.devicePixelRatio,this._updateParameters.renderingOptions= this.view.renderingOptions,this._updateParameters.targetState.copy(this.view.state),!this.view.animation||"then"in this.view.animation.target||(this._updateParameters.targetState.viewpoint=this.view.animation.target))};this.update=()=>{this._updateRequested=!1;if(!this.view?.destroyed){var {allLayerViews:c,graphicsView:b,labelManager:d,state:{id:e}}=this.view;c.forEach(this._updateLayerView,this);null!=d&&(d.lastUpdateId!==e&&(d.viewChange(),d.lastUpdateId=e),d.updateRequested&&d.processUpdate(this._updateParameters)); null!=b&&(b.lastUpdateId!==e&&(b.viewChange(),b.lastUpdateId=e),b.updateRequested&&b.processUpdate(this._updateParameters));this.view.graphicsTileStore.setViewState(this._updateParameters.state);this.animationInProgress||this._updateRequested||this._frameTaskHandle?.pause()}}}destroy(){this.stop()}start(){if(!this._frameTaskHandle){var a=this.view;this.stationary=a.stationary;this._updateParameters={state:a.state,targetState:new h,pixelRatio:window.devicePixelRatio,stationary:this.stationary,renderingOptions:a.renderingOptions}; this._stationaryHandle=f.watch(()=>a.stationary,c=>{this.stationary=c;this.requestFrame()});this._frameTaskHandle=g.addFrameTask(this);this.requestUpdate()}}stop(){this._frameTaskHandle&&(this._updateRequested=!1,this._stationaryHandle?.remove(),this._frameTaskHandle.remove(),this._updateParameters=this._stationaryHandle=this._frameTaskHandle=null,this.stationary=!0,this.animationInProgress=!1)}requestUpdate(){this._updateRequested||(this._updateRequested=!0,this.requestFrame())}requestFrame(){this._frameTaskHandle&& this._frameTaskHandle.resume()}_updateLayerView(a){if(a.attached){var c=this.view.state,b=a.lastUpdateId;if(null==b||!this.stationary&&!a.moving)a.moving=!0;b!==c.id&&a.viewChange();this.stationary&&a.moving&&(a.moving=!1,a.moveEnd());a.lastUpdateId=c.id;a.updateRequested&&a.processUpdate(this._updateParameters);"layerViews"in a&&a.layerViews?.forEach(this._updateLayerView,this)}else this.requestUpdate()}}return k});