/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as e}from"tslib";import"../../core/has.js";import r from"../../core/Logger.js";import{debounce as t,ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{property as o,cast as a,subclass as n}from"../../core/accessorSupport/decorators.js";import{excludeTables as i}from"../../core/accessorSupport/layerContainerType.js";import{registerLayer as h,unregisterLayer as p}from"./refresh.js";function m(e){return null!=e&&"object"==typeof e&&"refreshTimestamp"in e&&"refresh"in e}const f=.1,l=m=>{const l=m;let c=class extends l{constructor(...e){super(...e),this.refreshInterval=0,this.refreshTimestamp=0,this._debounceHasDataChanged=t(()=>this.hasDataChanged()),this.when().then(()=>{this.destroyed||h(this)},()=>{})}destroy(){p(this)}castRefreshInterval(e){return e>=f?e:e<=0?0:f}get refreshParameters(){return{_ts:this.refreshTimestamp||null}}refresh(e=Date.now()){s(this._debounceHasDataChanged()).then(r=>{r&&this._set("refreshTimestamp",e),this.emit("refresh",{dataChanged:r})},e=>{r.getLogger(this).error(e),this.emit("refresh",{dataChanged:!1,error:e})})}async hasDataChanged(){return!0}get test(){}};return e([o({type:Number,json:{write:!0,origins:{"web-scene":{write:{enabled:!0,layerContainerTypes:i}}}}})],c.prototype,"refreshInterval",void 0),e([a("refreshInterval")],c.prototype,"castRefreshInterval",null),e([o({readOnly:!0})],c.prototype,"refreshTimestamp",void 0),e([o({readOnly:!0})],c.prototype,"refreshParameters",null),c=e([n("esri.layers.mixins.RefreshableLayer")],c),c};export{l as RefreshableLayer,m as isRefreshableLayer};
