define(["exports","./../dom.js","./../emby-apiclient/connectionmanager.js","./../emby-elements/emby-button/emby-button.js","./../emby-elements/emby-button/paper-icon-button-light.js","./../common/recordinghelper.js"],function(_exports,_dom,_connectionmanager,_embyButton,_paperIconButtonLight,_recordinghelper){function RecordingButton(options){(this.options=options).item?this.refreshItem(options.item):options.itemId&&options.serverId&&this.refresh(options.itemId,options.serverId);var options=options.button,clickFn=(options.querySelector("i").innerHTML="&#xE061;",function(e){var serverId,programId,timerId,timerStatus,instance,item=this.item;item&&(serverId=item.ServerId,programId=item.Id,timerId=item.TimerId,timerStatus=item.Status,item=item.SeriesTimerId,instance=this,_recordinghelper.default.toggleRecording(serverId,programId,timerId,timerStatus,item).then(function(){instance.refresh(serverId,programId)}))}.bind(this));this.clickFn=clickFn,_dom.default.addEventListener(options,"click",clickFn,{passive:!0})}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,RecordingButton.prototype.refresh=function(serverId,itemId){var serverId=_connectionmanager.default.getApiClient(serverId),self=this;serverId.getItem(serverId.getCurrentUserId(),itemId).then(function(item){self.refreshItem(item)})},RecordingButton.prototype.refreshItem=function(item){var button=this.options.button;this.item=item,button.querySelector("i").innerHTML=function(item){var status;if("SeriesTimer"===item.Type)return"&#xE062;";if(item.TimerId||item.SeriesTimerId)status=item.Status||"Cancelled";else{if("Timer"!==item.Type)return"&#xE061;";status=item.Status}return item.SeriesTimerId&&"Cancelled"!==status?"&#xE062;":"&#xE061;"}(item),item.TimerId&&"Cancelled"!==(item.Status||"Cancelled")?button.classList.add("recordingIcon-active"):button.classList.remove("recordingIcon-active")},RecordingButton.prototype.destroy=function(){var clickFn,options=this.options;options&&(options=options.button,clickFn=this.clickFn)&&_dom.default.removeEventListener(options,"click",clickFn,{passive:!0}),this.options=null,this.item=null},_exports.default=RecordingButton});