var pu;!function(t){function e(t,e,i){if(t.addEventListener)t.addEventListener(e,i);else{var o=t;o.attachEvent?o.attachEvent("on"+e,i):o[e]=i}}function i(t,e){var i;return i="object"==typeof t?c(o(u(t),function(t){return"length"!==t}),function(e){return t[e]}):t,n(i,function(t){t.uploadStatus=e||t.uploadStatus,t.responseCode=t.responseCode||0,t.responseText=t.responseText||"",t.progress=t.progress||0,t.sentBytes=t.sentBytes||0,t.cancel=t.cancel||function(){}}),i}function o(t,e){var i=[];return t?(n(t,function(t){e(t)&&i.push(t)}),i):i}function n(t,e){if(t)for(var i=0;ie||0===t.size)},o.prototype.isFileTypeInvalid=function(t){if(t.name&&this.options.accept&&("*"!==this.options.accept.trim()||"*.*"!==this.options.accept.trim())&&this.options.validateExtension&&this.options.accept.indexOf("/")===-1){var e=this.options.accept.split(","),i=t.name.substring(t.name.lastIndexOf("."),t.name.length);if(i.indexOf(".")===-1)return!0;for(var o=!0,n=0;n=0&&(this.uploadAreas[e].destroy(),this.uploadAreas.splice(e,1))},t}();t.Uploader=m;var F=function(){function e(t,e){this.queuedFiles=[],this.options=t,this.callbacks=e,this.setFullOptions(),this.setFullCallbacks()}return e.prototype.addFiles=function(t){var e=this;n(t,function(t){e.queuedFiles.push(t),t.remove=s(t.remove,function(){e.removeFile(t)}),e.callbacks.onFileAddedCallback&&e.callbacks.onFileAddedCallback(t),t.uploadStatus===g.failed?e.callbacks.onErrorCallback&&e.callbacks.onErrorCallback(t):t.uploadStatus=g.queued}),this.filesChanged()},e.prototype.removeFile=function(t,e){void 0===e&&(e=!1);var i=p(this.queuedFiles,t);i<0||(this.deactivateFile(t),this.queuedFiles.splice(i,1),this.callbacks.onFileRemovedCallback&&this.callbacks.onFileRemovedCallback(t),e||this.filesChanged())},e.prototype.clearFiles=function(t,e){var i=this;void 0===t&&(t=[]),void 0===e&&(e=!1),e||(t=t.concat([g.queued,g.uploading])),n(o(this.queuedFiles,function(e){return p(t,e.uploadStatus)<0}),function(t){return i.removeFile(t,!0)}),this.callbacks.onQueueChangedCallback&&this.callbacks.onQueueChangedCallback(this.queuedFiles)},e.prototype.filesChanged=function(){this.options.autoRemove&&this.removeFinishedFiles(),this.options.autoStart&&this.startWaitingFiles(),this.callbacks.onQueueChangedCallback&&this.callbacks.onQueueChangedCallback(this.queuedFiles),this.checkAllFinished()},e.prototype.checkAllFinished=function(){var t=o(this.queuedFiles,function(t){return p([g.queued,g.uploading],t.uploadStatus)>=0});0===t.length&&this.callbacks.onAllFinishedCallback&&this.callbacks.onAllFinishedCallback()},e.prototype.setFullOptions=function(){this.options.maxParallelUploads=this.options.maxParallelUploads||0,this.options.autoStart=t.isFileApi&&(this.options.autoStart||!1),this.options.autoRemove=this.options.autoRemove||!1},e.prototype.setFullCallbacks=function(){var t=this;this.callbacks.onFileAddedCallback=this.callbacks.onFileAddedCallback||function(){},this.callbacks.onFileRemovedCallback=this.callbacks.onFileRemovedCallback||function(){},this.callbacks.onAllFinishedCallback=this.callbacks.onAllFinishedCallback||function(){},this.callbacks.onQueueChangedCallback=this.callbacks.onQueueChangedCallback||function(){},this.callbacks.onFileStateChangedCallback=function(){return t.filesChanged()}},e.prototype.startWaitingFiles=function(){n(this.getWaitingFiles(),function(t){return t.start()})},e.prototype.removeFinishedFiles=function(){var t=this;n(o(this.queuedFiles,function(t){return p([g.uploaded,g.canceled],t.uploadStatus)>=0}),function(e){return t.removeFile(e,!0)})},e.prototype.deactivateFile=function(t){t.uploadStatus===g.uploading&&t.cancel(),t.uploadStatus=g.removed,t.cancel=function(){},t.remove=function(){},t.start=function(){}},e.prototype.getWaitingFiles=function(){if(!this.options.autoStart)return[];var t=o(this.queuedFiles,function(t){return t.uploadStatus===g.queued});if(this.options.maxParallelUploads>0){var e=o(this.queuedFiles,function(t){return t.uploadStatus===g.uploading}).length,i=this.options.maxParallelUploads-e;if(i<=0)return[];t=t.slice(0,i)}return t},e}();t.UploadQueue=F;var g;!function(t){t[t.queued=0]="queued",t[t.uploading=1]="uploading",t[t.uploaded=2]="uploaded",t[t.failed=3]="failed",t[t.canceled=4]="canceled",t[t.removed=5]="removed"}(g=t.UploadStatus||(t.UploadStatus={}))}(pu||(pu={}));