(function(e){"function"===typeof define&&define.amd?define(["jquery","load-image","canvas-to-blob","./jquery.fileupload.min"],e):e(window.jQuery,window.loadImage)})(function(e,g){e.widget("blueimp.fileupload",e.blueimp.fileupload,{options:{process:[],add:function(b,d){e(this).fileupload("process",d).done(function(){d.submit()})}},processActions:{load:function(b,d){var c=this,a=b.files[b.index],f=e.Deferred();window.HTMLCanvasElement&&window.HTMLCanvasElement.prototype.toBlob&&("number"!==e.type(d.maxFileSize)||
a.size<d.maxFileSize)&&(!d.fileTypes||d.fileTypes.test(a.type))?g(a,function(a){b.img=a;f.resolveWith(c,[b])}):f.rejectWith(c,[b]);return f.promise()},resize:function(b,d){var c=b.img,a;d=e.extend({canvas:!0},d);if(c&&(a=g.scale(c,d),a.width!==c.width||a.height!==c.height))b.canvas=a;return b},save:function(b){if(!b.canvas)return b;var d=this,c=b.files[b.index],a=c.name,f=e.Deferred(),h=function(a){a.name||(c.type===a.type?a.name=c.name:c.name&&(a.name=c.name.replace(/\..+$/,"."+a.type.substr(6))));
b.files[b.index]=a;f.resolveWith(d,[b])};b.canvas.mozGetAsFile?h(b.canvas.mozGetAsFile(/^image\/(jpeg|png)$/.test(c.type)&&a||(a&&a.replace(/\..+$/,"")||"blob")+".png",c.type)):b.canvas.toBlob(h,c.type);return f.promise()}},_processFile:function(b,d,c){var a=this,f=e.Deferred().resolveWith(a,[{files:b,index:d}]).promise();a._processing+=1;e.each(c.process,function(b,c){f=f.pipe(function(b){return a.processActions[c.action].call(this,b,c)})});f.always(function(){a._processing-=1;0===a._processing&&
a.element.removeClass("fileupload-processing")});1===a._processing&&a.element.addClass("fileupload-processing");return f},process:function(b){var d=this,c=e.extend({},this.options,b);c.process&&(c.process.length&&this._isXHRUpload(c))&&e.each(b.files,function(a){d._processingQueue=d._processingQueue.pipe(function(){var f=e.Deferred();d._processFile(b.files,a,c).always(function(){f.resolveWith(d)});return f.promise()})});return this._processingQueue},_create:function(){this._super();this._processing=
0;this._processingQueue=e.Deferred().resolveWith(this).promise()}})});