define(["exports","./servicelocator.js","./../emby-apiclient/events.js"],function(_exports,_servicelocator,_events){function onInterval(){this._lastInterval=Date.now();var options=this.options;options&&options.onInterval()}function MethodTimer(options){this.options=options,this.boundOnAppResume=function(){var options,started=this.isStarted();this.stopInterval(),started&&((started=this._lastInterval)&&(options=this.options)&&started+options.timeoutMs<=Date.now()&&onInterval.call(this),this.startInterval())}.bind(this),this.boundOnInterval=onInterval.bind(this),_events.default.on(_servicelocator.appHost,"resume",this.boundOnAppResume),this.startInterval()}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,MethodTimer.prototype.stopInterval=function(){this._interval&&(("interval"===this._intervalType?clearInterval:clearTimeout)(this._interval),this._interval=null,this._intervalType=null)},MethodTimer.prototype.startInterval=function(){this._lastInterval=Date.now(),"interval"===this.options.type?(this._interval=setInterval(this.boundOnInterval,this.options.timeoutMs),this._intervalType="interval"):this._interval=setTimeout(this.boundOnInterval,this.options.timeoutMs)},MethodTimer.prototype.isStarted=function(){return null!=this._interval},MethodTimer.prototype.destroy=function(){this.options=null,this.boundOnAppResume&&(_events.default.off(_servicelocator.appHost,"resume",this.boundOnAppResume),this.boundOnAppResume=null),this.stopInterval(),this.boundOnInterval=null,this._lastInterval=null};_exports.default=MethodTimer});