(function(e){"use strict";if(typeof define==="function"&&define.amd){define(["jquery","angular","./jquery.fileupload-image.min","./jquery.fileupload-audio.min","./jquery.fileupload-video.min","./jquery.fileupload-validate.min"],e)}else{e()}})(function(){"use strict";angular.module("blueimp.fileupload",[]).provider("fileUpload",function(){var e=function(e){var o=angular.element(this).fileupload("option","scope")();o.$evalAsync(e)},t=function(e,n){var o=n.files,r=o[0];angular.forEach(o,function(e,o){e._index=o;e.$state=function(){return n.state()};e.$processing=function(){return n.processing()};e.$progress=function(){return n.progress()};e.$response=function(){return n.response()}});r.$submit=function(){if(!r.error){return n.submit()}};r.$cancel=function(){return n.abort()}},o;o=this.defaults={handleResponse:function(e,o){var n=o.result&&o.result.files;if(n){o.scope().replace(o.files,n)}else if(o.errorThrown||o.textStatus==="error"){o.files[0].error=o.errorThrown||o.textStatus}},add:function(e,o){if(e.isDefaultPrevented()){return false}var n=o.scope(),r=[];angular.forEach(o.files,function(e){r.push(e)});n.$apply(function(){t(n,o);var e=n.option("prependFiles")?"unshift":"push";Array.prototype[e].apply(n.queue,o.files)});o.process(function(){return n.process(o)}).always(function(){n.$apply(function(){t(n,o);n.replace(r,o.files)})}).then(function(){if((n.option("autoUpload")||o.autoUpload)&&o.autoUpload!==false){o.submit()}})},progress:function(e,o){if(e.isDefaultPrevented()){return false}o.scope().$apply()},done:function(e,o){if(e.isDefaultPrevented()){return false}var n=this;o.scope().$apply(function(){o.handleResponse.call(n,e,o)})},fail:function(e,o){if(e.isDefaultPrevented()){return false}var n=this,r=o.scope();if(o.errorThrown==="abort"){r.clear(o.files);return}r.$apply(function(){o.handleResponse.call(n,e,o)})},stop:e,processstart:e,processstop:e,getNumberOfFiles:function(){var e=this.scope();return e.queue.length-e.processing()},dataType:"json",autoUpload:false};this.$get=[function(){return{defaults:o}}]}).provider("formatFileSizeFilter",function(){var i={units:[{size:1e9,suffix:" GB"},{size:1e6,suffix:" MB"},{size:1e3,suffix:" KB"}]};this.defaults=i;this.$get=function(){return function(e){if(!angular.isNumber(e)){return""}var o=true,n=0,r,t;while(o){o=i.units[n];r=o.prefix||"";t=o.suffix||"";if(n===i.units.length-1||e>=o.size){return r+(e/o.size).toFixed(2)+t}n+=1}}}}).controller("FileUploadController",["$scope","$element","$attrs","$window","fileUpload",function(n,r,e,o,t){var i={progress:function(){return r.fileupload("progress")},active:function(){return r.fileupload("active")},option:function(e,o){return r.fileupload("option",e,o)},add:function(e){return r.fileupload("add",e)},send:function(e){return r.fileupload("send",e)},process:function(e){return r.fileupload("process",e)},processing:function(e){return r.fileupload("processing",e)}};n.disabled=!o.jQuery.support.fileInput;n.queue=n.queue||[];n.clear=function(e){var o=this.queue,n=o.length,r=e,t=1;if(angular.isArray(e)){r=e[0];t=e.length}while(n){n-=1;if(o[n]===r){return o.splice(n,t)}}};n.replace=function(e,o){var n=this.queue,r=e[0],t,i;for(t=0;t<n.length;t+=1){if(n[t]===r){for(i=0;i<o.length;i+=1){n[t+i]=o[i]}return}}};n.applyOnQueue=function(e){var o=this.queue.slice(0),n,r;for(n=0;n<o.length;n+=1){r=o[n];if(r[e]){r[e]()}}};n.submit=function(){this.applyOnQueue("$submit")};n.cancel=function(){this.applyOnQueue("$cancel")};angular.extend(n,i);r.fileupload(angular.extend({scope:function(){return n}},t.defaults)).on("fileuploadadd",function(e,o){o.scope=n.option("scope")}).on("fileuploadfail",function(e,o){if(o.errorThrown==="abort"){return}if(o.dataType&&o.dataType.indexOf("json")===o.dataType.length-4){try{o.result=angular.fromJson(o.jqXHR.responseText)}catch(e){}}}).on(["fileuploadadd","fileuploadsubmit","fileuploadsend","fileuploaddone","fileuploadfail","fileuploadalways","fileuploadprogress","fileuploadprogressall","fileuploadstart","fileuploadstop","fileuploadchange","fileuploadpaste","fileuploaddrop","fileuploaddragover","fileuploadchunksend","fileuploadchunkdone","fileuploadchunkfail","fileuploadchunkalways","fileuploadprocessstart","fileuploadprocess","fileuploadprocessdone","fileuploadprocessfail","fileuploadprocessalways","fileuploadprocessstop"].join(" "),function(e,o){if(n.$emit(e.type,o).defaultPrevented){e.preventDefault()}}).on("remove",function(){var e;for(e in i){if(i.hasOwnProperty(e)){delete n[e]}}});n.$watch(e.fileUpload,function(e){if(e){r.fileupload("option",e)}})}]).controller("FileUploadProgressController",["$scope","$attrs","$parse",function(o,e,n){var r=n(e.fileUploadProgress),t=function(){var e=r(o);if(!e||!e.total){return}o.num=Math.floor(e.loaded/e.total*100)};t();o.$watch(e.fileUploadProgress+".loaded",function(e,o){if(e!==o){t()}})}]).controller("FileUploadPreviewController",["$scope","$element","$attrs",function(e,o,n){e.$watch(n.fileUploadPreview+".preview",function(e){o.empty();if(e){o.append(e)}})}]).directive("fileUpload",function(){return{controller:"FileUploadController",scope:true}}).directive("fileUploadProgress",function(){return{controller:"FileUploadProgressController",scope:true}}).directive("fileUploadPreview",function(){return{controller:"FileUploadPreviewController"}}).directive("download",function(){return function(e,o){o.on("dragstart",function(e){try{e.originalEvent.dataTransfer.setData("DownloadURL",["application/octet-stream",o.prop("download"),o.prop("href")].join(":"))}catch(e){}})}})});