define(["ember","app","moment","mm","broad"],function(a,b,c,d){return d.post(["download"],{module:"messageHost",action:"sendEvent"}),b.DownloadController=a.ObjectController.extend({thumbSize:"72w_72h",items:function(){var b=this;return this.get("model")?this.get("model").map(function(d){var e,f=d.get("id"),g=d.get("FileType"),h=d.get("Tag2");if("image"===g&&(e="icon"===h?f:f+"@"+b.get("thumbSize")),"audio"===g&&(e="../assets/images/volume.png"),"video"===g){var i=f.lastIndexOf(".");e=f.substr(0,i)+"_preview.png"}return a.Object.create({thumb:e,percent:0,percentStyle:"width:0%",createdDate:c(d.get("_created_date")).format("YYYY-MM-DD"),entity:d,selected:!0})}):[]}.property("model"),initialize:function(){var a=this;d.listener.on("download",function(b,c){var d=a.get("items"),e=d.find(function(a){return a.get("entity.id")==c.url});e&&("process"==c.status&&(e.set("percent",c.percent),e.set("percentStyle","width:"+c.percent+"%")),"process"==c.status&&c.percent>=100&&d.removeObject(e))})}.on("init"),selectedItems:function(){return this.get("items").filter(function(a){return a.get("selected")})}.property("items.@each.selected"),actions:{toggleSelect:function(a){a.set("selected",!a.get("selected"))},resume:function(){this.get("selectedItems").forEach(function(a){d.post({url:a.get("entity.id")},{module:"fileManager",action:"resume"})})},stop:function(){this.get("selectedItems").forEach(function(a){d.post({url:a.get("entity.id")},{module:"fileManager",action:"pause"})})}}})});