define(["exports","./../../modules/common/itemmanager/itemmanager.js","./../../modules/common/itemmanager/baseitemcontroller.js","./../../modules/emby-apiclient/connectionmanager.js","./../../modules/common/globalize.js"],function(_exports,_itemmanager,_baseitemcontroller,_connectionmanager,_globalize){function SyncJobController(){_baseitemcontroller.default.apply(this,arguments)}function getDeleteMessages(item){var title,text,confirmText=_globalize.default.translate("Remove");return"Convert"===item.SyncJobType?item.SyncNewContent||"Completed"!==item.Status?(title=_globalize.default.translate("CancelConversion"),text="ConfirmCancelConversion",confirmText=_globalize.default.translate("CancelConversion")):(title=_globalize.default.translate("RemoveFromHistory"),text="ConfirmRemoveFromHistory"):(title=_globalize.default.translate("RemoveDownload"),text="ConfirmRemoveDownload"),{single:{text:text,title:title,confirmText:confirmText},plural:{text:text,title:title,confirmText:confirmText}}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,Object.assign(SyncJobController.prototype,_baseitemcontroller.default.prototype),SyncJobController.prototype.getTypeNames=function(){return["SyncJob"]},SyncJobController.prototype.getDisplayName=function(item,options){return item.Name},SyncJobController.prototype.isSingleItemFetchRequired=function(typeName){return!1},SyncJobController.prototype.getDefaultIcon=function(item){return"&#xe627;"},SyncJobController.prototype.canDelete=function(item,user){return!0},SyncJobController.prototype.enableLibraryItemDeleteConfirmation=function(){return!1},SyncJobController.prototype.canRate=function(item){return!1},SyncJobController.prototype.canMarkPlayed=function(item){return!1},SyncJobController.prototype.canAddToPlaylist=function(item){return!1},SyncJobController.prototype.canAddToCollection=function(item,user){return!1},SyncJobController.prototype.canConvert=function(item,user){return!1},SyncJobController.prototype.canEdit=function(items,user){return 1===items.length},SyncJobController.prototype.canEditImages=function(item,user){return!1},SyncJobController.prototype.canEditSubtitles=function(item,user){return!1},SyncJobController.prototype.isDeletePrimaryCommand=function(itemType){return!0},SyncJobController.prototype.getDeleteCommand=function(items){var item=items[0],itemType=item.Type,item=getDeleteMessages(item);return{name:(1<items.length?item.plural:item.single).title,id:"delete",icon:"remove_circle_outline",primaryCommand:this.isDeletePrimaryCommand(itemType)}},SyncJobController.prototype.getDeleteMessages=getDeleteMessages,SyncJobController.prototype.canRefreshMetadata=function(item,user){return!1},SyncJobController.prototype.deleteItemsInternal=function(options){for(var isLocalTarget,apiClient=_connectionmanager.default.getApiClient(options.items[0]),localTargetId=_connectionmanager.default.deviceId(),ids=[],i=0,length=options.items.length;i<length;i++){var item=options.items[i];ids.push(item.Id),item.TargetId===localTargetId&&(isLocalTarget=!0)}return apiClient.cancelSyncJobs(ids).then(function(result){return isLocalTarget&&require(["localsync"],function(localSync){localSync.sync()}),Promise.resolve(result)})},SyncJobController.prototype.getNameSortOption=function(itemType){return null},SyncJobController.prototype.editItems=function(items,options){var item=items[0];return Emby.importModule("./modules/sync/syncjobeditor.js").then(function(syncJobEditor){return syncJobEditor.show({serverId:item.ServerId,jobId:item.Id,mode:"Convert"===item.SyncJobType?"convert":"download"})})},SyncJobController.prototype.resolveField=function(item,field){switch(field){case"SyncJobItemCount":return 1===item.ItemCount?_globalize.default.translate("ValueOneItem"):_globalize.default.translate("ItemCount",item.ItemCount);case"SyncJobProgress":var job=item,status=job.Status;switch(status){case"Completed":status="Convert"===job.SyncJobType?_globalize.default.translate("Converted"):_globalize.default.translate("Downloaded");break;case"Failed":case"Cancelled":status=_globalize.default.translate(status);break;default:status=_globalize.default.translate("SyncJobItemStatus"+status)}var progress,html=status;return"Transferring"!==job.Status&&"Converting"!==job.Status||job.Progress&&(html=(html+=" ")+(progress=0<(progress=job.Progress||0)&&progress<100?progress.toFixed(1):progress)+"%"),html;default:return _baseitemcontroller.default.prototype.resolveField.apply(this,arguments)}};var instance=new SyncJobController;_itemmanager.default.registerItemController(instance),_exports.default=instance});