// All material copyright ESRI, All Rights Reserved, unless otherwise specified.// See https://js.arcgis.com/4.6/esri/copyright.txt for details.//>>builtdefine("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper ../core/accessorSupport/decorators ../core/Accessor ../core/HandleRegistry".split(" "),function(n,p,h,f,e,k,l){returnfunction(g){functionb(){vara=null!==g&&g.apply(this,arguments)||this;a._handles=newl;a._currentTick=0;returna}h(b,g);b.prototype.initialize=function(){vara=this;this.view.allLayerViews.on("after-changes",function(){a.notifyChange("tickInterval");a._handles.remove("layerViewsUpdating");a._handles.add(a._getLayerViewHandles(),"layerViewsUpdating")});this.watch("tickInterval",function(){returna._restartTicking()});this.watch("view.ready",function(){returna._restartTicking()});this._restartTicking()};b.prototype.destroy=function(){this._handles&&(this._handles.destroy(),this._handles=null,this._intervalID&&clearInterval(this._intervalID),this._currentTick=0)};Object.defineProperty(b.prototype,"tickInterval",{get:function(){vara=this.view.allLayerViews.filter(function(a){return!!a.refresh});returnthis._getCommonInterval(a)},enumerable:!0,configurable:!0});b.prototype._restartTicking=function(){vara=this;this._currentTick=0;this._intervalID&&clearInterval(this._intervalID);this.get("view.ready")&&(this._intervalID=setInterval(function(){varb=Date.now();a._currentTick+=a.tickInterval;a.view.allLayerViews.forEach(function(d){if(d.refresh){varc=Math.round(6E4*d.refreshInterval),m=0===a._currentTick%c,e=6E3>b-d.refreshTimestamp;c&&m&&!e&&d.refresh(b)}})},this.tickInterval))};b.prototype._getLayerViewHandles=function(){vara=this,b=[];this.view.allLayerViews.forEach(function(d){if(d.refresh){varc=d.watch("refreshInterval",function(){returna.notifyChange("tickInterval")});b.push(c);d.layer&&(c=d.layer.on("refresh",function(){vara=Date.now();6E3>a-d.refreshTimestamp||d.refresh(a)}),b.push(c))}});returnb};b.prototype._getCommonInterval=function(a){varb=function(a,c){returnisNaN(a)||isNaN(c)?0:0>=c?a:b(c,a%c)};returna.toArray().reduce(function(a,c){returnb(Math.round(6E4*c.refreshInterval),a)},0)};f([e.property()],b.prototype,"view",void0);f([e.property({readOnly:!0})],b.prototype,"tickInterval",null);returnb=f([e.subclass("esri.views.RefreshManager")],b)}(e.declared(k))});