diff --git a/app/api.rb b/app/api.rb
index 8009a91e..61073e19 100644
--- a/app/api.rb
+++ b/app/api.rb
@@ -42,13 +42,33 @@ get '/api/list' do
end
def extract_files(params, files = [])
- params.each do |key, value|
- # If the value is a Hash and contains a :tempfile key, it's considered an uploaded file.
- if value.is_a?(Hash) && value.has_key?(:tempfile) && !value[:tempfile].nil?
- files << {filename: value[:name], tempfile: value[:tempfile]}
- elsif value.is_a?(Hash) || value.is_a?(Array)
- # If the value is a Hash or Array, recursively search for more files.
- extract_files(value, files)
+ # Check if the entire input is directly an array of files
+ if params.is_a?(Array)
+ params.each do |item|
+ # Call extract_files on each item if it's an Array or Hash to handle nested structures
+ if item.is_a?(Array) || item.is_a?(Hash)
+ extract_files(item, files)
+ end
+ end
+ elsif params.is_a?(Hash)
+ params.each do |key, value|
+ # If the value is a Hash and contains a :tempfile key, it's considered an uploaded file.
+ if value.is_a?(Hash) && value.has_key?(:tempfile) && !value[:tempfile].nil?
+ files << {filename: value[:name], tempfile: value[:tempfile]}
+ elsif value.is_a?(Array)
+ value.each do |val|
+ if val.is_a?(Hash) && val.has_key?(:tempfile) && !val[:tempfile].nil?
+ # Directly add the file info if it's an uploaded file within an array
+ files << {filename: val[:name], tempfile: val[:tempfile]}
+ elsif val.is_a?(Hash) || val.is_a?(Array)
+ # Recursively search for more files if the element is a Hash or Array
+ extract_files(val, files)
+ end
+ end
+ elsif value.is_a?(Hash)
+ # Recursively search for more files if the value is a Hash
+ extract_files(value, files)
+ end
end
end
files
@@ -56,9 +76,22 @@ end
post '/api/upload' do
require_api_credentials
-
files = extract_files params
+ if !params[:username].blank?
+ site = Site[username: params[:username]]
+
+ if site.nil? || site.is_deleted
+ api_error 400, 'site_not_found', "could not find site"
+ end
+
+ if site.owned_by?(current_site)
+ @_site = site
+ else
+ api_error 400, 'site_not_allowed', "not allowed to change this site with your current logged in site"
+ end
+ end
+
api_error 400, 'missing_files', 'you must provide files to upload' if files.empty?
uploaded_size = files.collect {|f| f[:tempfile].size}.inject{|sum,x| sum + x }
@@ -68,16 +101,28 @@ post '/api/upload' do
end
if current_site.too_many_files?(files.length)
- api_error 400, 'too_many_files', "cannot exceed the maximum site files limit (#{current_site.plan_feature(:maximum_site_files)}), #{current_site.supporter? ? 'please contact support' : 'please upgrade to a supporter account'}"
+ api_error 400, 'too_many_files', "cannot exceed the maximum site files limit (#{current_site.plan_feature(:maximum_site_files)})"
end
files.each do |file|
if !current_site.okay_to_upload?(file)
- api_error 400, 'invalid_file_type', "#{file[:filename]} is not a valid file type (or contains not allowed content) for this site, files have not been uploaded"
+ api_error 400, 'invalid_file_type', "#{file[:filename]} is not a allowed file type for free sites, supporter required"
end
if File.directory? file[:filename]
- api_error 400, 'directory_exists', 'this name is being used by a directory, cannot continue'
+ api_error 400, 'directory_exists', "#{file[:filename]} being used by a directory"
+ end
+
+ if current_site.file_size_too_large? file[:tempfile].size
+ api_error 400, 'file_too_large' "#{file[:filename]} is too large"
+ end
+
+ if SiteFile.path_too_long? file[:filename]
+ api_error 400, 'file_path_too_long', "#{file[:filename]} path is too long"
+ end
+
+ if SiteFile.name_too_long? file[:filename]
+ api_error 400, 'file_name_too_long', "#{file[:filename]} filename is too long"
end
end
@@ -191,7 +236,7 @@ post '/api/:name' do
end
def require_api_credentials
- return true if current_site
+ return true if current_site && csrf_safe?
if !request.env['HTTP_AUTHORIZATION'].nil?
init_api_credentials
diff --git a/app/dashboard.rb b/app/dashboard.rb
index f7616472..cbba9701 100644
--- a/app/dashboard.rb
+++ b/app/dashboard.rb
@@ -8,7 +8,7 @@ get '/dashboard' do
current_site.save_changes validate: false
end
- erb :'dashboard'
+ erb :'dashboard/index'
end
def dashboard_init
@@ -30,3 +30,11 @@ def dashboard_init
@dir = params[:dir]
@file_list = current_site.file_list @dir
end
+
+get '/dashboard/files' do
+ require_login
+ dashboard_init
+ dont_browser_cache
+
+ erb :'dashboard/files', layout: false
+end
\ No newline at end of file
diff --git a/app/site_files.rb b/app/site_files.rb
index f183dacc..d60be51b 100644
--- a/app/site_files.rb
+++ b/app/site_files.rb
@@ -75,7 +75,9 @@ post '/site_files/create' do
end
def file_upload_response(error=nil)
- flash[:error] = error if error
+ if error
+ flash[:error] = error
+ end
if params[:from_button]
query_string = params[:dir] ? "?"+Rack::Utils.build_query(dir: params[:dir]) : ''
@@ -90,77 +92,6 @@ def require_login_file_upload_ajax
file_upload_response 'You are not signed in!' unless signed_in?
end
-post '/site_files/upload' do
- if params[:filename]
- require_login_file_upload_ajax
- tempfile = Tempfile.new 'neocities_saving_file'
-
- input = request.body.read
- tempfile.set_encoding input.encoding
- tempfile.write input
- tempfile.close
-
- params[:files] = [{filename: params[:filename], tempfile: tempfile}]
- else
- require_login
- end
-
- @errors = []
-
- if params[:files].nil?
- file_upload_response "Uploaded files were not seen by the server, cancelled. We don't know what's causing this yet. Please contact us so we can help fix it. Thanks!"
- end
-
- # For migration from original design.. some pages out there won't have the site_id param yet for a while.
- site = params[:site_id].nil? ? current_site : Site[params[:site_id]]
-
- unless site.owned_by?(current_site)
- file_upload_response 'You do not have permission to save this file. Did you sign in as a different user?'
- end
-
- params[:files].each_with_index do |file,i|
- dir_name = ''
- dir_name = params[:dir] if params[:dir]
-
- unless params[:file_paths].nil? || params[:file_paths].empty? || params[:file_paths].length == 0
- file_path = params[:file_paths][i]
- unless file_path.nil?
- dir_name += '/' + Pathname(file_path).dirname.to_s
- end
- end
-
- file_base_name = site.scrubbed_path file[:filename].force_encoding('UTF-8')
-
- file[:filename] = "#{dir_name.force_encoding('UTF-8')}/#{file_base_name}"
-
- if current_site.file_size_too_large? file[:tempfile].size
- file_upload_response "#{Rack::Utils.escape_html file[:filename]} is too large, upload cancelled."
- end
- if !site.okay_to_upload? file
- file_upload_response %{#{Rack::Utils.escape_html file[:filename]}: file type (or content in file) is only supported by supporter accounts. Why We Do This}
- end
- if SiteFile.path_too_long? file[:filename]
- file_upload_response "#{Rack::Utils.escape_html file[:filename]}: path is too long, upload cancelled."
- end
- if SiteFile.name_too_long? file_base_name
- file_upload_response "#{Rack::Utils.escape_html file[:filename]}: file name is too long, upload cancelled."
- end
- end
-
- uploaded_size = params[:files].collect {|f| f[:tempfile].size}.inject{|sum,x| sum + x }
-
- if site.file_size_too_large? uploaded_size
- file_upload_response "File(s) do not fit in your available free space, upload cancelled."
- end
-
- if site.too_many_files? params[:files].length
- file_upload_response "Your site has exceeded the maximum number of files, please delete some files first."
- end
-
- results = site.store_files params[:files]
- file_upload_response
-end
-
post '/site_files/delete' do
require_login
path = HTMLEntities.new.decode params[:filename]
@@ -246,7 +177,16 @@ get %r{\/site_files\/text_editor\/(.+)} do
dont_browser_cache
@filename = params[:captures].first
+ redirect '/site_files/text_editor?filename=' + Rack::Utils.escape(@filename)
+end
+
+get '/site_files/text_editor' do
+ require_login
+ dont_browser_cache
+
+ @filename = params[:filename]
extname = File.extname @filename
+
@ace_mode = case extname
when /htm|html/ then 'html'
when /js/ then 'javascript'
@@ -286,4 +226,4 @@ end
get '/site_files/mount_info' do
@title = 'Site Mount Information'
erb :'site_files/mount_info'
-end
+end
\ No newline at end of file
diff --git a/app_helpers.rb b/app_helpers.rb
index df0d4991..a8ba94e7 100644
--- a/app_helpers.rb
+++ b/app_helpers.rb
@@ -131,3 +131,15 @@ def hcaptcha_valid?
false
end
end
+
+JS_ESCAPE_MAP = {"\\" => "\\\\", "" => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'", "`" => "\\`", "$" => "\\$"}
+
+def escape_javascript(javascript)
+ javascript = javascript.to_s
+ if javascript.empty?
+ result = ""
+ else
+ result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"']|[`]|[$])/u, JS_ESCAPE_MAP)
+ end
+ result
+end
\ No newline at end of file
diff --git a/models/site.rb b/models/site.rb
index f7b246a0..a590b167 100644
--- a/models/site.rb
+++ b/models/site.rb
@@ -84,7 +84,7 @@ class Site < Sequel::Model
SCREENSHOT_RESOLUTIONS = ['540x405', '210x158', '100x100', '50x50']
THUMBNAIL_RESOLUTIONS = ['210x158']
- MAX_FILE_SIZE = 10**8 # 100 MB
+ MAX_FILE_SIZE = 10**8 # 100 MB, change dashboard.js dropzone file size limit if you change this
CLAMAV_THREAT_MATCHES = [
/^VBS/,
diff --git a/public/img/drag-drop.png b/public/img/drag-drop.png
deleted file mode 100644
index aa608569..00000000
Binary files a/public/img/drag-drop.png and /dev/null differ
diff --git a/public/img/drag-drop.svg b/public/img/drag-drop.svg
new file mode 100644
index 00000000..56577a04
--- /dev/null
+++ b/public/img/drag-drop.svg
@@ -0,0 +1,58 @@
+
+
+
+
diff --git a/public/js/dashboard.js b/public/js/dashboard.js
new file mode 100644
index 00000000..33eb40d2
--- /dev/null
+++ b/public/js/dashboard.js
@@ -0,0 +1,157 @@
+if(localStorage && localStorage.getItem('viewType') == 'list')
+ $('#filesDisplay').addClass('list-view')
+
+function confirmFileRename(path) {
+ $('#renamePathInput').val(path);
+ $('#renameNewPathInput').val(path);
+ $('#renameModal').modal();
+}
+
+function confirmFileDelete(name) {
+ $('#deleteFileName').text(name);
+ $('#deleteConfirmModal').modal();
+}
+
+function fileDelete() {
+ $('#deleteFilenameInput').val($('#deleteFileName').html());
+ $('#deleteFilenameForm').submit();
+}
+
+function clickUploadFiles() {
+ $("input[id='uploadFiles']").click()
+}
+
+function showUploadProgress() {
+ $('#uploadingOverlay').css('display', 'block')
+}
+
+function hideUploadProgress() {
+ $('#progressBar').css('display', 'none')
+ $('#uploadingOverlay').css('display', 'none')
+}
+
+$('#createDir').on('shown', function () {
+ $('#newDirInput').focus();
+})
+
+$('#createFile').on('shown', function () {
+ $('#newFileInput').focus();
+})
+
+function listView() {
+ if(localStorage)
+ localStorage.setItem('viewType', 'list')
+
+ $('#filesDisplay').addClass('list-view')
+}
+
+function iconView() {
+ if(localStorage)
+ localStorage.removeItem('viewType')
+
+ $('#filesDisplay').removeClass('list-view')
+}
+
+function alertAdd(text) {
+ var a = $('#alertDialogue');
+ a.css('display', 'block');
+ a.append(text+' ');
+}
+
+function alertClear(){
+ var a = $('#alertDialogue');
+ a.css('display', 'none');
+ a.text('');
+}
+
+function alertType(type){
+ var a = $('#alertDialogue');
+ a.removeClass('alert-success');
+ a.removeClass('alert-error');
+ a.addClass('alert-'+type);
+}
+
+var processedFiles = 0;
+var uploadedFiles = 0;
+var uploadedFileErrors = 0;
+
+function joinPaths(...paths) {
+ return paths
+ .map(path => path.replace(/(^\/|\/$)/g, ''))
+ .filter(path => path !== '')
+ .join('/');
+}
+
+function reInitDashboardFiles() {
+ new Dropzone("#uploads", {
+ url: "/api/upload",
+ paramName: 'file',
+ dictDefaultMessage: "",
+ uploadMultiple: false,
+ parallelUploads: 1,
+ maxFilesize: 104857600, // 100MB
+ clickable: document.getElementById('uploadButton'),
+ init: function() {
+ this.on("processing", function(file) {
+ var dir = $('#uploads input[name="dir"]').val();
+ if(file.fullPath) {
+ this.options.paramName = joinPaths(dir,file.fullPath);
+ } else {
+ this.options.paramName = joinPaths(dir, file.name);
+ }
+
+ processedFiles++;
+ $('#uploadFileName').text(this.options.paramName).prepend(' ');
+ });
+
+ this.on("success", function(file) {
+ uploadedFiles++;
+ });
+
+ this.on("error", function(file, message) {
+ uploadedFiles++;
+ uploadedFileErrors++;
+ alertType('error');
+ if (message && message.message) {
+ alertAdd(message.message);
+ } else {
+ alertAdd(this.options.paramName+' failed to upload');
+ }
+ });
+
+ this.on("queuecomplete", function() {
+ hideUploadProgress();
+ if(uploadedFileErrors > 0) {
+ alertType('error');
+ alertAdd(uploadedFiles-uploadedFileErrors+'/'+uploadedFiles+' files uploaded successfully');
+ } else {
+ alertType('success');
+ alertAdd(uploadedFiles+' files uploaded successfully');
+ }
+ reloadDashboardFiles();
+ });
+
+ this.on("addedfiles", function(files) {
+ uploadedFiles = 0;
+ uploadedFileErrors = 0;
+ alertClear();
+ showUploadProgress();
+ });
+ }
+ });
+
+ document.getElementById('uploadButton').addEventListener('click', function(event) {
+ event.preventDefault();
+ });
+}
+
+function reloadDashboardFiles() {
+ var dir = $('#uploads input[name="dir"]').val();
+ $.get('/dashboard/files?dir='+encodeURIComponent(dir), function(data) {
+ $('#filesDisplay').html(data);
+ reInitDashboardFiles();
+ });
+}
+
+// for first time load
+reInitDashboardFiles();
diff --git a/public/js/dropzone-min.js b/public/js/dropzone-min.js
new file mode 100644
index 00000000..cfced120
--- /dev/null
+++ b/public/js/dropzone-min.js
@@ -0,0 +1,2 @@
+!function(){function e(e){return e&&e.__esModule?e.default:e}function t(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var i=0;i1?t-1:0),n=1;n'),this.element.appendChild(e));var l=e.getElementsByTagName("span")[0];return l&&(null!=l.textContent?l.textContent=this.options.dictFallbackMessage:null!=l.innerText&&(l.innerText=this.options.dictFallbackMessage)),this.element.appendChild(this.getFallbackForm())},resize:function(e,t,i,n){var r={srcX:0,srcY:0,srcWidth:e.width,srcHeight:e.height},a=e.width/e.height;null==t&&null==i?(t=r.srcWidth,i=r.srcHeight):null==t?t=i*a:null==i&&(i=t/a);var o=(t=Math.min(t,r.srcWidth))/(i=Math.min(i,r.srcHeight));if(r.srcWidth>t||r.srcHeight>i)if("crop"===n)a>o?(r.srcHeight=e.height,r.srcWidth=r.srcHeight*o):(r.srcWidth=e.width,r.srcHeight=r.srcWidth/o);else{if("contain"!==n)throw new Error("Unknown resizeMethod '".concat(n,"'"));a>o?i=t/a:t=i*a}return r.srcX=(e.width-r.srcWidth)/2,r.srcY=(e.height-r.srcHeight)/2,r.trgWidth=t,r.trgHeight=i,r},transformFile:function(e,t){return(this.options.resizeWidth||this.options.resizeHeight)&&e.type.match(/image.*/)?this.resizeImage(e,this.options.resizeWidth,this.options.resizeHeight,this.options.resizeMethod,t):t(e)},previewTemplate:e('
'),drop:function(e){return this.element.classList.remove("dz-drag-hover")},dragstart:function(e){},dragend:function(e){return this.element.classList.remove("dz-drag-hover")},dragenter:function(e){return this.element.classList.add("dz-drag-hover")},dragover:function(e){return this.element.classList.add("dz-drag-hover")},dragleave:function(e){return this.element.classList.remove("dz-drag-hover")},paste:function(e){},reset:function(){return this.element.classList.remove("dz-started")},addedfile:function(e){if(this.element===this.previewsContainer&&this.element.classList.add("dz-started"),this.previewsContainer&&!this.options.disablePreviews){var t=this;e.previewElement=f.createElement(this.options.previewTemplate.trim()),e.previewTemplate=e.previewElement,this.previewsContainer.appendChild(e.previewElement);var i=!0,n=!1,r=void 0;try{for(var a,o=e.previewElement.querySelectorAll("[data-dz-name]")[Symbol.iterator]();!(i=(a=o.next()).done);i=!0){var l=a.value;l.textContent=e.name}}catch(e){n=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(n)throw r}}var s=!0,u=!1,c=void 0;try{for(var d,h=e.previewElement.querySelectorAll("[data-dz-size]")[Symbol.iterator]();!(s=(d=h.next()).done);s=!0)(l=d.value).innerHTML=this.filesize(e.size)}catch(e){u=!0,c=e}finally{try{s||null==h.return||h.return()}finally{if(u)throw c}}this.options.addRemoveLinks&&(e._removeLink=f.createElement(''.concat(this.options.dictRemoveFile,"")),e.previewElement.appendChild(e._removeLink));var p=function(i){var n=t;if(i.preventDefault(),i.stopPropagation(),e.status===f.UPLOADING)return f.confirm(t.options.dictCancelUploadConfirmation,(function(){return n.removeFile(e)}));var r=t;return t.options.dictRemoveFileConfirmation?f.confirm(t.options.dictRemoveFileConfirmation,(function(){return r.removeFile(e)})):t.removeFile(e)},m=!0,v=!1,y=void 0;try{for(var g,b=e.previewElement.querySelectorAll("[data-dz-remove]")[Symbol.iterator]();!(m=(g=b.next()).done);m=!0){g.value.addEventListener("click",p)}}catch(e){v=!0,y=e}finally{try{m||null==b.return||b.return()}finally{if(v)throw y}}}},removedfile:function(e){return null!=e.previewElement&&null!=e.previewElement.parentNode&&e.previewElement.parentNode.removeChild(e.previewElement),this._updateMaxFilesReachedClass()},thumbnail:function(e,t){if(e.previewElement){e.previewElement.classList.remove("dz-file-preview");var i=!0,n=!1,r=void 0;try{for(var a,o=e.previewElement.querySelectorAll("[data-dz-thumbnail]")[Symbol.iterator]();!(i=(a=o.next()).done);i=!0){var l=a.value;l.alt=e.name,l.src=t}}catch(e){n=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(n)throw r}}return setTimeout((function(){return e.previewElement.classList.add("dz-image-preview")}),1)}},error:function(e,t){if(e.previewElement){e.previewElement.classList.add("dz-error"),"string"!=typeof t&&t.error&&(t=t.error);var i=!0,n=!1,r=void 0;try{for(var a,o=e.previewElement.querySelectorAll("[data-dz-errormessage]")[Symbol.iterator]();!(i=(a=o.next()).done);i=!0){a.value.textContent=t}}catch(e){n=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(n)throw r}}}},errormultiple:function(){},processing:function(e){if(e.previewElement&&(e.previewElement.classList.add("dz-processing"),e._removeLink))return e._removeLink.innerHTML=this.options.dictCancelUpload},processingmultiple:function(){},uploadprogress:function(e,t,i){var n=!0,r=!1,a=void 0;if(e.previewElement)try{for(var o,l=e.previewElement.querySelectorAll("[data-dz-uploadprogress]")[Symbol.iterator]();!(n=(o=l.next()).done);n=!0){var s=o.value;"PROGRESS"===s.nodeName?s.value=t:s.style.width="".concat(t,"%")}}catch(e){r=!0,a=e}finally{try{n||null==l.return||l.return()}finally{if(r)throw a}}},totaluploadprogress:function(){},sending:function(){},sendingmultiple:function(){},success:function(e){if(e.previewElement)return e.previewElement.classList.add("dz-success")},successmultiple:function(){},canceled:function(e){return this.emit("error",e,this.options.dictUploadCanceled)},canceledmultiple:function(){},complete:function(e){if(e._removeLink&&(e._removeLink.innerHTML=this.options.dictRemoveFile),e.previewElement)return e.previewElement.classList.add("dz-complete")},completemultiple:function(){},maxfilesexceeded:function(){},maxfilesreached:function(){},queuecomplete:function(){},addedfiles:function(){}},f=function(n){"use strict";function o(n,r){var l,c,d,h;if(i(this,o),(l=s(this,(c=o,a(c)).call(this))).element=n,l.clickableElements=[],l.listeners=[],l.files=[],"string"==typeof l.element&&(l.element=document.querySelector(l.element)),!l.element||null==l.element.nodeType)throw new Error("Invalid dropzone element.");if(l.element.dropzone)throw new Error("Dropzone already attached.");o.instances.push(t(l)),l.element.dropzone=t(l);var f=null!=(h=o.optionsForElement(l.element))?h:{};if(l.options=e(u)(!0,{},p,f,null!=r?r:{}),l.options.previewTemplate=l.options.previewTemplate.replace(/\n*/g,""),l.options.forceFallback||!o.isBrowserSupported())return s(l,l.options.fallback.call(t(l)));if(null==l.options.url&&(l.options.url=l.element.getAttribute("action")),!l.options.url)throw new Error("No URL provided.");if(l.options.acceptedFiles&&l.options.acceptedMimeTypes)throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");if(l.options.uploadMultiple&&l.options.chunking)throw new Error("You cannot set both: uploadMultiple and chunking.");if(l.options.binaryBody&&l.options.uploadMultiple)throw new Error("You cannot set both: binaryBody and uploadMultiple.");return l.options.acceptedMimeTypes&&(l.options.acceptedFiles=l.options.acceptedMimeTypes,delete l.options.acceptedMimeTypes),null!=l.options.renameFilename&&(l.options.renameFile=function(e){return l.options.renameFilename.call(t(l),e.name,e)}),"string"==typeof l.options.method&&(l.options.method=l.options.method.toUpperCase()),(d=l.getExistingFallback())&&d.parentNode&&d.parentNode.removeChild(d),!1!==l.options.previewsContainer&&(l.options.previewsContainer?l.previewsContainer=o.getElement(l.options.previewsContainer,"previewsContainer"):l.previewsContainer=l.element),l.options.clickable&&(!0===l.options.clickable?l.clickableElements=[l.element]:l.clickableElements=o.getElements(l.options.clickable,"clickable")),l.init(),l}return l(o,n),r(o,[{key:"getAcceptedFiles",value:function(){return this.files.filter((function(e){return e.accepted})).map((function(e){return e}))}},{key:"getRejectedFiles",value:function(){return this.files.filter((function(e){return!e.accepted})).map((function(e){return e}))}},{key:"getFilesWithStatus",value:function(e){return this.files.filter((function(t){return t.status===e})).map((function(e){return e}))}},{key:"getQueuedFiles",value:function(){return this.getFilesWithStatus(o.QUEUED)}},{key:"getUploadingFiles",value:function(){return this.getFilesWithStatus(o.UPLOADING)}},{key:"getAddedFiles",value:function(){return this.getFilesWithStatus(o.ADDED)}},{key:"getActiveFiles",value:function(){return this.files.filter((function(e){return e.status===o.UPLOADING||e.status===o.QUEUED})).map((function(e){return e}))}},{key:"init",value:function(){var e=this,t=this,i=this,n=this,r=this,a=this,l=this,s=this,u=this,c=this,d=this;if("form"===this.element.tagName&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector(".dz-message")&&this.element.appendChild(o.createElement('"))),this.clickableElements.length){var h=this,p=function(){var e=h;h.hiddenFileInput&&h.hiddenFileInput.parentNode.removeChild(h.hiddenFileInput),h.hiddenFileInput=document.createElement("input"),h.hiddenFileInput.setAttribute("type","file"),(null===h.options.maxFiles||h.options.maxFiles>1)&&h.hiddenFileInput.setAttribute("multiple","multiple"),h.hiddenFileInput.className="dz-hidden-input",null!==h.options.acceptedFiles&&h.hiddenFileInput.setAttribute("accept",h.options.acceptedFiles),null!==h.options.capture&&h.hiddenFileInput.setAttribute("capture",h.options.capture),h.hiddenFileInput.setAttribute("tabindex","-1"),h.hiddenFileInput.style.visibility="hidden",h.hiddenFileInput.style.position="absolute",h.hiddenFileInput.style.top="0",h.hiddenFileInput.style.left="0",h.hiddenFileInput.style.height="0",h.hiddenFileInput.style.width="0",o.getElement(h.options.hiddenInputContainer,"hiddenInputContainer").appendChild(h.hiddenFileInput),h.hiddenFileInput.addEventListener("change",(function(){var t=e.hiddenFileInput.files,i=!0,n=!1,r=void 0;if(t.length)try{for(var a,o=t[Symbol.iterator]();!(i=(a=o.next()).done);i=!0){var l=a.value;e.addFile(l)}}catch(e){n=!0,r=e}finally{try{i||null==o.return||o.return()}finally{if(n)throw r}}e.emit("addedfiles",t),p()}))};p()}this.URL=null!==window.URL?window.URL:window.webkitURL;var f=!0,m=!1,v=void 0;try{for(var y,g=this.events[Symbol.iterator]();!(f=(y=g.next()).done);f=!0){var b=y.value;this.on(b,this.options[b])}}catch(e){m=!0,v=e}finally{try{f||null==g.return||g.return()}finally{if(m)throw v}}this.on("uploadprogress",(function(){return e.updateTotalUploadProgress()})),this.on("removedfile",(function(){return t.updateTotalUploadProgress()})),this.on("canceled",(function(e){return i.emit("complete",e)})),this.on("complete",(function(e){var t=n;if(0===n.getAddedFiles().length&&0===n.getUploadingFiles().length&&0===n.getQueuedFiles().length)return setTimeout((function(){return t.emit("queuecomplete")}),0)}));var k=function(e){if(function(e){if(e.dataTransfer.types)for(var t=0;t".concat(this.options.dictFallbackText,"
")),i+='');var n=o.createElement(i);return"FORM"!==this.element.tagName?(t=o.createElement(''))).appendChild(n):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=t?t:n}},{key:"getExistingFallback",value:function(){var e=function(e){var t=!0,i=!1,n=void 0;try{for(var r,a=e[Symbol.iterator]();!(t=(r=a.next()).done);t=!0){var o=r.value;if(/(^| )fallback($| )/.test(o.className))return o}}catch(e){i=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(i)throw n}}},t=!0,i=!1,n=void 0;try{for(var r,a=["div","form"][Symbol.iterator]();!(t=(r=a.next()).done);t=!0){var o,l=r.value;if(o=e(this.element.getElementsByTagName(l)))return o}}catch(e){i=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(i)throw n}}}},{key:"setupEventListeners",value:function(){return this.listeners.map((function(e){return function(){var t=[];for(var i in e.events){var n=e.events[i];t.push(e.element.addEventListener(i,n,!1))}return t}()}))}},{key:"removeEventListeners",value:function(){return this.listeners.map((function(e){return function(){var t=[];for(var i in e.events){var n=e.events[i];t.push(e.element.removeEventListener(i,n,!1))}return t}()}))}},{key:"disable",value:function(){var e=this;return this.clickableElements.forEach((function(e){return e.classList.remove("dz-clickable")})),this.removeEventListeners(),this.disabled=!0,this.files.map((function(t){return e.cancelUpload(t)}))}},{key:"enable",value:function(){return delete this.disabled,this.clickableElements.forEach((function(e){return e.classList.add("dz-clickable")})),this.setupEventListeners()}},{key:"filesize",value:function(e){var t=0,i="b";if(e>0){for(var n=["tb","gb","mb","kb","b"],r=0;r=Math.pow(this.options.filesizeBase,4-r)/10){t=e/Math.pow(this.options.filesizeBase,4-r),i=a;break}}t=Math.round(10*t)/10}return"".concat(t," ").concat(this.options.dictFileSizeUnits[i])}},{key:"_updateMaxFilesReachedClass",value:function(){return null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(this.getAcceptedFiles().length===this.options.maxFiles&&this.emit("maxfilesreached",this.files),this.element.classList.add("dz-max-files-reached")):this.element.classList.remove("dz-max-files-reached")}},{key:"drop",value:function(e){if(e.dataTransfer){this.emit("drop",e);for(var t=[],i=0;i0){var n=!0,r=!1,o=void 0;try{for(var l,s=i[Symbol.iterator]();!(n=(l=s.next()).done);n=!0){var u=l.value,c=e;u.isFile?u.file((function(e){if(!c.options.ignoreHiddenFiles||"."!==e.name.substring(0,1))return e.fullPath="".concat(t,"/").concat(e.name),c.addFile(e)})):u.isDirectory&&e._addFilesFromDirectory(u,"".concat(t,"/").concat(u.name))}}catch(e){r=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(r)throw o}}a()}return null}),r)};return a()}},{key:"accept",value:function(e,t){this.options.maxFilesize&&e.size>1048576*this.options.maxFilesize?t(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(e.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):o.isValidFile(e,this.options.acceptedFiles)?null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(t(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}",this.options.maxFiles)),this.emit("maxfilesexceeded",e)):this.options.accept.call(this,e,t):t(this.options.dictInvalidFileType)}},{key:"addFile",value:function(e){var t=this;e.upload={uuid:o.uuidv4(),progress:0,total:e.size,bytesSent:0,filename:this._renameFile(e)},this.files.push(e),e.status=o.ADDED,this.emit("addedfile",e),this._enqueueThumbnail(e),this.accept(e,(function(i){i?(e.accepted=!1,t._errorProcessing([e],i)):(e.accepted=!0,t.options.autoQueue&&t.enqueueFile(e)),t._updateMaxFilesReachedClass()}))}},{key:"enqueueFiles",value:function(e){var t=!0,i=!1,n=void 0;try{for(var r,a=e[Symbol.iterator]();!(t=(r=a.next()).done);t=!0){var o=r.value;this.enqueueFile(o)}}catch(e){i=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(i)throw n}}return null}},{key:"enqueueFile",value:function(e){if(e.status!==o.ADDED||!0!==e.accepted)throw new Error("This file can't be queued because it has already been processed or was rejected.");var t=this;if(e.status=o.QUEUED,this.options.autoProcessQueue)return setTimeout((function(){return t.processQueue()}),0)}},{key:"_enqueueThumbnail",value:function(e){if(this.options.createImageThumbnails&&e.type.match(/image.*/)&&e.size<=1048576*this.options.maxThumbnailFilesize){var t=this;return this._thumbnailQueue.push(e),setTimeout((function(){return t._processThumbnailQueue()}),0)}}},{key:"_processThumbnailQueue",value:function(){var e=this;if(!this._processingThumbnail&&0!==this._thumbnailQueue.length){this._processingThumbnail=!0;var t=this._thumbnailQueue.shift();return this.createThumbnail(t,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,!0,(function(i){return e.emit("thumbnail",t,i),e._processingThumbnail=!1,e._processThumbnailQueue()}))}}},{key:"removeFile",value:function(e){if(e.status===o.UPLOADING&&this.cancelUpload(e),this.files=m(this.files,e),this.emit("removedfile",e),0===this.files.length)return this.emit("reset")}},{key:"removeAllFiles",value:function(e){null==e&&(e=!1);var t=!0,i=!1,n=void 0;try{for(var r,a=this.files.slice()[Symbol.iterator]();!(t=(r=a.next()).done);t=!0){var l=r.value;(l.status!==o.UPLOADING||e)&&this.removeFile(l)}}catch(e){i=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(i)throw n}}return null}},{key:"resizeImage",value:function(e,t,i,n,r){var a=this;return this.createThumbnail(e,t,i,n,!0,(function(t,i){if(null==i)return r(e);var n=a.options.resizeMimeType;null==n&&(n=e.type);var l=i.toDataURL(n,a.options.resizeQuality);return"image/jpeg"!==n&&"image/jpg"!==n||(l=g.restore(e.dataURL,l)),r(o.dataURItoBlob(l))}))}},{key:"createThumbnail",value:function(e,t,i,n,r,a){var o=this,l=new FileReader;l.onload=function(){e.dataURL=l.result,"image/svg+xml"!==e.type?o.createThumbnailFromUrl(e,t,i,n,r,a):null!=a&&a(l.result)},l.readAsDataURL(e)}},{key:"displayExistingFile",value:function(e,t,i,n,r){var a=void 0===r||r;if(this.emit("addedfile",e),this.emit("complete",e),a){var o=this;e.dataURL=t,this.createThumbnailFromUrl(e,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,this.options.fixOrientation,(function(t){o.emit("thumbnail",e,t),i&&i()}),n)}else this.emit("thumbnail",e,t),i&&i()}},{key:"createThumbnailFromUrl",value:function(e,t,i,n,r,a,o){var l=this,s=document.createElement("img");return o&&(s.crossOrigin=o),r="from-image"!=getComputedStyle(document.body).imageOrientation&&r,s.onload=function(){var o=l,u=function(e){return e(1)};return"undefined"!=typeof EXIF&&null!==EXIF&&r&&(u=function(e){return EXIF.getData(s,(function(){return e(EXIF.getTag(this,"Orientation"))}))}),u((function(r){e.width=s.width,e.height=s.height;var l=o.options.resize.call(o,e,t,i,n),u=document.createElement("canvas"),c=u.getContext("2d");switch(u.width=l.trgWidth,u.height=l.trgHeight,r>4&&(u.width=l.trgHeight,u.height=l.trgWidth),r){case 2:c.translate(u.width,0),c.scale(-1,1);break;case 3:c.translate(u.width,u.height),c.rotate(Math.PI);break;case 4:c.translate(0,u.height),c.scale(1,-1);break;case 5:c.rotate(.5*Math.PI),c.scale(1,-1);break;case 6:c.rotate(.5*Math.PI),c.translate(0,-u.width);break;case 7:c.rotate(.5*Math.PI),c.translate(u.height,-u.width),c.scale(-1,1);break;case 8:c.rotate(-.5*Math.PI),c.translate(-u.height,0)}y(c,s,null!=l.srcX?l.srcX:0,null!=l.srcY?l.srcY:0,l.srcWidth,l.srcHeight,null!=l.trgX?l.trgX:0,null!=l.trgY?l.trgY:0,l.trgWidth,l.trgHeight);var d=u.toDataURL("image/png");if(null!=a)return a(d,u)}))},null!=a&&(s.onerror=a),s.src=e.dataURL}},{key:"processQueue",value:function(){var e=this.options.parallelUploads,t=this.getUploadingFiles().length,i=t;if(!(t>=e)){var n=this.getQueuedFiles();if(n.length>0){if(this.options.uploadMultiple)return this.processFiles(n.slice(0,e-t));for(;i1?t-1:0),n=1;nt.options.chunkSize),e[0].upload.totalChunkCount=Math.ceil(n.size/t.options.chunkSize)}if(e[0].upload.chunked){var r=t,a=t,l=e[0];n=i[0];l.upload.chunks=[];var s=function(){for(var t=0;void 0!==l.upload.chunks[t];)t++;if(!(t>=l.upload.totalChunkCount)){0;var i=t*r.options.chunkSize,a=Math.min(i+r.options.chunkSize,n.size),s={name:r._getParamName(0),data:n.webkitSlice?n.webkitSlice(i,a):n.slice(i,a),filename:l.upload.filename,chunkIndex:t};l.upload.chunks[t]={file:l,index:t,dataBlock:s,status:o.UPLOADING,progress:0,retries:0},r._uploadData(e,[s])}};if(l.upload.finishedChunkUpload=function(t,i){var n=a,r=!0;t.status=o.SUCCESS,t.dataBlock=null,t.response=t.xhr.responseText,t.responseHeaders=t.xhr.getAllResponseHeaders(),t.xhr=null;for(var u=0;u=o;l?a++:a--)r[a]=t.charCodeAt(a);return new Blob([n],{type:i})};var m=function(e,t){return e.filter((function(e){return e!==t})).map((function(e){return e}))},v=function(e){return e.replace(/[\-_](\w)/g,(function(e){return e.charAt(1).toUpperCase()}))};f.createElement=function(e){var t=document.createElement("div");return t.innerHTML=e,t.childNodes[0]},f.elementInside=function(e,t){if(e===t)return!0;for(;e=e.parentNode;)if(e===t)return!0;return!1},f.getElement=function(e,t){var i;if("string"==typeof e?i=document.querySelector(e):null!=e.nodeType&&(i=e),null==i)throw new Error("Invalid `".concat(t,"` option provided. Please provide a CSS selector or a plain HTML element."));return i},f.getElements=function(e,t){var i,n;if(e instanceof Array){n=[];try{var r=!0,a=!1,o=void 0;try{for(var l=e[Symbol.iterator]();!(r=(s=l.next()).done);r=!0)i=s.value,n.push(this.getElement(i,t))}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}}catch(e){n=null}}else if("string"==typeof e){n=[];r=!0,a=!1,o=void 0;try{var s;for(l=document.querySelectorAll(e)[Symbol.iterator]();!(r=(s=l.next()).done);r=!0)i=s.value,n.push(i)}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}}else null!=e.nodeType&&(n=[e]);if(null==n||!n.length)throw new Error("Invalid `".concat(t,"` option provided. Please provide a CSS selector, a plain HTML element or a list of those."));return n},f.confirm=function(e,t,i){return window.confirm(e)?t():null!=i?i():void 0},f.isValidFile=function(e,t){if(!t)return!0;t=t.split(",");var i=e.type,n=i.replace(/\/.*$/,""),r=!0,a=!1,o=void 0;try{for(var l,s=t[Symbol.iterator]();!(r=(l=s.next()).done);r=!0){var u=l.value;if("."===(u=u.trim()).charAt(0)){if(-1!==e.name.toLowerCase().indexOf(u.toLowerCase(),e.name.length-u.length))return!0}else if(/\/\*$/.test(u)){if(n===u.replace(/\/.*$/,""))return!0}else if(i===u)return!0}}catch(e){a=!0,o=e}finally{try{r||null==s.return||s.return()}finally{if(a)throw o}}return!1},"undefined"!=typeof jQuery&&null!==jQuery&&(jQuery.fn.dropzone=function(e){return this.each((function(){return new f(this,e)}))}),f.ADDED="added",f.QUEUED="queued",f.ACCEPTED=f.QUEUED,f.UPLOADING="uploading",f.PROCESSING=f.UPLOADING,f.CANCELED="canceled",f.ERROR="error",f.SUCCESS="success";var y=function(e,t,i,n,r,a,o,l,s,u){var c=function(e){e.naturalWidth;var t=e.naturalHeight,i=document.createElement("canvas");i.width=1,i.height=t;var n=i.getContext("2d");n.drawImage(e,0,0);for(var r=n.getImageData(1,0,1,t).data,a=0,o=t,l=t;l>a;)0===r[4*(l-1)+3]?o=l:a=l,l=o+a>>1;var s=l/t;return 0===s?1:s}(t);return e.drawImage(t,i,n,r,a,o,l,s,u/c)},g=function(){"use strict";function e(){i(this,e)}return r(e,null,[{key:"initClass",value:function(){this.KEY_STR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}},{key:"encode64",value:function(e){for(var t="",i=void 0,n=void 0,r="",a=void 0,o=void 0,l=void 0,s="",u=0;a=(i=e[u++])>>2,o=(3&i)<<4|(n=e[u++])>>4,l=(15&n)<<2|(r=e[u++])>>6,s=63&r,isNaN(n)?l=s=64:isNaN(r)&&(s=64),t=t+this.KEY_STR.charAt(a)+this.KEY_STR.charAt(o)+this.KEY_STR.charAt(l)+this.KEY_STR.charAt(s),i=n=r="",a=o=l=s="",ue.length)break}return i}},{key:"decode64",value:function(e){var t=void 0,i=void 0,n="",r=void 0,a=void 0,o="",l=0,s=[];for(/[^A-Za-z0-9\+\/\=]/g.exec(e)&&console.warn("There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\nExpect errors in decoding."),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");t=this.KEY_STR.indexOf(e.charAt(l++))<<2|(r=this.KEY_STR.indexOf(e.charAt(l++)))>>4,i=(15&r)<<4|(a=this.KEY_STR.indexOf(e.charAt(l++)))>>2,n=(3&a)<<6|(o=this.KEY_STR.indexOf(e.charAt(l++))),s.push(t),64!==a&&s.push(i),64!==o&&s.push(n),t=i=n="",r=a=o="",l'\n );\n this.element.appendChild(messageElement);\n }\n\n let span = messageElement.getElementsByTagName(\"span\")[0];\n if (span) {\n if (span.textContent != null) {\n span.textContent = this.options.dictFallbackMessage;\n } else if (span.innerText != null) {\n span.innerText = this.options.dictFallbackMessage;\n }\n }\n\n return this.element.appendChild(this.getFallbackForm());\n },\n\n /**\n * Gets called to calculate the thumbnail dimensions.\n *\n * It gets `file`, `width` and `height` (both may be `null`) as parameters and must return an object containing:\n *\n * - `srcWidth` & `srcHeight` (required)\n * - `trgWidth` & `trgHeight` (required)\n * - `srcX` & `srcY` (optional, default `0`)\n * - `trgX` & `trgY` (optional, default `0`)\n *\n * Those values are going to be used by `ctx.drawImage()`.\n */\n resize(file, width, height, resizeMethod) {\n let info = {\n srcX: 0,\n srcY: 0,\n srcWidth: file.width,\n srcHeight: file.height,\n };\n\n let srcRatio = file.width / file.height;\n\n // Automatically calculate dimensions if not specified\n if (width == null && height == null) {\n width = info.srcWidth;\n height = info.srcHeight;\n } else if (width == null) {\n width = height * srcRatio;\n } else if (height == null) {\n height = width / srcRatio;\n }\n\n // Make sure images aren't upscaled\n width = Math.min(width, info.srcWidth);\n height = Math.min(height, info.srcHeight);\n\n let trgRatio = width / height;\n\n if (info.srcWidth > width || info.srcHeight > height) {\n // Image is bigger and needs rescaling\n if (resizeMethod === \"crop\") {\n if (srcRatio > trgRatio) {\n info.srcHeight = file.height;\n info.srcWidth = info.srcHeight * trgRatio;\n } else {\n info.srcWidth = file.width;\n info.srcHeight = info.srcWidth / trgRatio;\n }\n } else if (resizeMethod === \"contain\") {\n // Method 'contain'\n if (srcRatio > trgRatio) {\n height = width / srcRatio;\n } else {\n width = height * srcRatio;\n }\n } else {\n throw new Error(`Unknown resizeMethod '${resizeMethod}'`);\n }\n }\n\n info.srcX = (file.width - info.srcWidth) / 2;\n info.srcY = (file.height - info.srcHeight) / 2;\n\n info.trgWidth = width;\n info.trgHeight = height;\n\n return info;\n },\n\n /**\n * Can be used to transform the file (for example, resize an image if necessary).\n *\n * The default implementation uses `resizeWidth` and `resizeHeight` (if provided) and resizes\n * images according to those dimensions.\n *\n * Gets the `file` as the first parameter, and a `done()` function as the second, that needs\n * to be invoked with the file when the transformation is done.\n */\n transformFile(file, done) {\n if (\n (this.options.resizeWidth || this.options.resizeHeight) &&\n file.type.match(/image.*/)\n ) {\n return this.resizeImage(\n file,\n this.options.resizeWidth,\n this.options.resizeHeight,\n this.options.resizeMethod,\n done\n );\n } else {\n return done(file);\n }\n },\n\n /**\n * A string that contains the template used for each dropped\n * file. Change it to fulfill your needs but make sure to properly\n * provide all elements.\n *\n * If you want to use an actual HTML element instead of providing a String\n * as a config option, you could create a div with the id `tpl`,\n * put the template inside it and provide the element like this:\n *\n * document\n * .querySelector('#tpl')\n * .innerHTML\n *\n */\n previewTemplate: defaultPreviewTemplate,\n\n /*\n Those functions register themselves to the events on init and handle all\n the user interface specific stuff. Overwriting them won't break the upload\n but can break the way it's displayed.\n You can overwrite them if you don't like the default behavior. If you just\n want to add an additional event handler, register it on the dropzone object\n and don't overwrite those options.\n */\n\n // Those are self explanatory and simply concern the DragnDrop.\n drop(e) {\n return this.element.classList.remove(\"dz-drag-hover\");\n },\n dragstart(e) {},\n dragend(e) {\n return this.element.classList.remove(\"dz-drag-hover\");\n },\n dragenter(e) {\n return this.element.classList.add(\"dz-drag-hover\");\n },\n dragover(e) {\n return this.element.classList.add(\"dz-drag-hover\");\n },\n dragleave(e) {\n return this.element.classList.remove(\"dz-drag-hover\");\n },\n\n paste(e) {},\n\n // Called whenever there are no files left in the dropzone anymore, and the\n // dropzone should be displayed as if in the initial state.\n reset() {\n return this.element.classList.remove(\"dz-started\");\n },\n\n // Called when a file is added to the queue\n // Receives `file`\n addedfile(file) {\n if (this.element === this.previewsContainer) {\n this.element.classList.add(\"dz-started\");\n }\n\n if (this.previewsContainer && !this.options.disablePreviews) {\n file.previewElement = Dropzone.createElement(\n this.options.previewTemplate.trim()\n );\n file.previewTemplate = file.previewElement; // Backwards compatibility\n\n this.previewsContainer.appendChild(file.previewElement);\n for (var node of file.previewElement.querySelectorAll(\"[data-dz-name]\")) {\n node.textContent = file.name;\n }\n for (node of file.previewElement.querySelectorAll(\"[data-dz-size]\")) {\n node.innerHTML = this.filesize(file.size);\n }\n\n if (this.options.addRemoveLinks) {\n file._removeLink = Dropzone.createElement(\n `${this.options.dictRemoveFile}`\n );\n file.previewElement.appendChild(file._removeLink);\n }\n\n let removeFileEvent = (e) => {\n e.preventDefault();\n e.stopPropagation();\n if (file.status === Dropzone.UPLOADING) {\n return Dropzone.confirm(\n this.options.dictCancelUploadConfirmation,\n () => this.removeFile(file)\n );\n } else {\n if (this.options.dictRemoveFileConfirmation) {\n return Dropzone.confirm(\n this.options.dictRemoveFileConfirmation,\n () => this.removeFile(file)\n );\n } else {\n return this.removeFile(file);\n }\n }\n };\n\n for (let removeLink of file.previewElement.querySelectorAll(\n \"[data-dz-remove]\"\n )) {\n removeLink.addEventListener(\"click\", removeFileEvent);\n }\n }\n },\n\n // Called whenever a file is removed.\n removedfile(file) {\n if (file.previewElement != null && file.previewElement.parentNode != null) {\n file.previewElement.parentNode.removeChild(file.previewElement);\n }\n return this._updateMaxFilesReachedClass();\n },\n\n // Called when a thumbnail has been generated\n // Receives `file` and `dataUrl`\n thumbnail(file, dataUrl) {\n if (file.previewElement) {\n file.previewElement.classList.remove(\"dz-file-preview\");\n for (let thumbnailElement of file.previewElement.querySelectorAll(\n \"[data-dz-thumbnail]\"\n )) {\n thumbnailElement.alt = file.name;\n thumbnailElement.src = dataUrl;\n }\n\n return setTimeout(\n () => file.previewElement.classList.add(\"dz-image-preview\"),\n 1\n );\n }\n },\n\n // Called whenever an error occurs\n // Receives `file` and `message`\n error(file, message) {\n if (file.previewElement) {\n file.previewElement.classList.add(\"dz-error\");\n if (typeof message !== \"string\" && message.error) {\n message = message.error;\n }\n for (let node of file.previewElement.querySelectorAll(\n \"[data-dz-errormessage]\"\n )) {\n node.textContent = message;\n }\n }\n },\n\n errormultiple() {},\n\n // Called when a file gets processed. Since there is a cue, not all added\n // files are processed immediately.\n // Receives `file`\n processing(file) {\n if (file.previewElement) {\n file.previewElement.classList.add(\"dz-processing\");\n if (file._removeLink) {\n return (file._removeLink.innerHTML = this.options.dictCancelUpload);\n }\n }\n },\n\n processingmultiple() {},\n\n // Called whenever the upload progress gets updated.\n // Receives `file`, `progress` (percentage 0-100) and `bytesSent`.\n // To get the total number of bytes of the file, use `file.size`\n uploadprogress(file, progress, bytesSent) {\n if (file.previewElement) {\n for (let node of file.previewElement.querySelectorAll(\n \"[data-dz-uploadprogress]\"\n )) {\n node.nodeName === \"PROGRESS\"\n ? (node.value = progress)\n : (node.style.width = `${progress}%`);\n }\n }\n },\n\n // Called whenever the total upload progress gets updated.\n // Called with totalUploadProgress (0-100), totalBytes and totalBytesSent\n totaluploadprogress() {},\n\n // Called just before the file is sent. Gets the `xhr` object as second\n // parameter, so you can modify it (for example to add a CSRF token) and a\n // `formData` object to add additional information.\n sending() {},\n\n sendingmultiple() {},\n\n // When the complete upload is finished and successful\n // Receives `file`\n success(file) {\n if (file.previewElement) {\n return file.previewElement.classList.add(\"dz-success\");\n }\n },\n\n successmultiple() {},\n\n // When the upload is canceled.\n canceled(file) {\n return this.emit(\"error\", file, this.options.dictUploadCanceled);\n },\n\n canceledmultiple() {},\n\n // When the upload is finished, either with success or an error.\n // Receives `file`\n complete(file) {\n if (file._removeLink) {\n file._removeLink.innerHTML = this.options.dictRemoveFile;\n }\n if (file.previewElement) {\n return file.previewElement.classList.add(\"dz-complete\");\n }\n },\n\n completemultiple() {},\n\n maxfilesexceeded() {},\n\n maxfilesreached() {},\n\n queuecomplete() {},\n\n addedfiles() {},\n};\n\nexport default defaultOptions;\n","module.exports = \"d07f0bb239092071\";","import extend from \"just-extend\";\nimport Emitter from \"./emitter\";\nimport defaultOptions from \"./options\";\n\nexport default class Dropzone extends Emitter {\n static initClass() {\n // Exposing the emitter class, mainly for tests\n this.prototype.Emitter = Emitter;\n\n /*\n This is a list of all available events you can register on a dropzone object.\n\n You can register an event handler like this:\n\n dropzone.on(\"dragEnter\", function() { });\n\n */\n this.prototype.events = [\n \"drop\",\n \"dragstart\",\n \"dragend\",\n \"dragenter\",\n \"dragover\",\n \"dragleave\",\n \"addedfile\",\n \"addedfiles\",\n \"removedfile\",\n \"thumbnail\",\n \"error\",\n \"errormultiple\",\n \"processing\",\n \"processingmultiple\",\n \"uploadprogress\",\n \"totaluploadprogress\",\n \"sending\",\n \"sendingmultiple\",\n \"success\",\n \"successmultiple\",\n \"canceled\",\n \"canceledmultiple\",\n \"complete\",\n \"completemultiple\",\n \"reset\",\n \"maxfilesexceeded\",\n \"maxfilesreached\",\n \"queuecomplete\",\n ];\n\n this.prototype._thumbnailQueue = [];\n this.prototype._processingThumbnail = false;\n }\n\n constructor(el, options) {\n super();\n let fallback, left;\n this.element = el;\n\n this.clickableElements = [];\n this.listeners = [];\n this.files = []; // All files\n\n if (typeof this.element === \"string\") {\n this.element = document.querySelector(this.element);\n }\n\n // Not checking if instance of HTMLElement or Element since IE9 is extremely weird.\n if (!this.element || this.element.nodeType == null) {\n throw new Error(\"Invalid dropzone element.\");\n }\n\n if (this.element.dropzone) {\n throw new Error(\"Dropzone already attached.\");\n }\n\n // Now add this dropzone to the instances.\n Dropzone.instances.push(this);\n\n // Put the dropzone inside the element itself.\n this.element.dropzone = this;\n\n let elementOptions =\n (left = Dropzone.optionsForElement(this.element)) != null ? left : {};\n\n this.options = extend(\n true,\n {},\n defaultOptions,\n elementOptions,\n options != null ? options : {}\n );\n\n this.options.previewTemplate = this.options.previewTemplate.replace(\n /\\n*/g,\n \"\"\n );\n\n // If the browser failed, just call the fallback and leave\n if (this.options.forceFallback || !Dropzone.isBrowserSupported()) {\n return this.options.fallback.call(this);\n }\n\n // @options.url = @element.getAttribute \"action\" unless @options.url?\n if (this.options.url == null) {\n this.options.url = this.element.getAttribute(\"action\");\n }\n\n if (!this.options.url) {\n throw new Error(\"No URL provided.\");\n }\n\n if (this.options.acceptedFiles && this.options.acceptedMimeTypes) {\n throw new Error(\n \"You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.\"\n );\n }\n\n if (this.options.uploadMultiple && this.options.chunking) {\n throw new Error(\"You cannot set both: uploadMultiple and chunking.\");\n }\n\n if (this.options.binaryBody && this.options.uploadMultiple) {\n throw new Error(\"You cannot set both: binaryBody and uploadMultiple.\");\n }\n\n // Backwards compatibility\n if (this.options.acceptedMimeTypes) {\n this.options.acceptedFiles = this.options.acceptedMimeTypes;\n delete this.options.acceptedMimeTypes;\n }\n\n // Backwards compatibility\n if (this.options.renameFilename != null) {\n this.options.renameFile = (file) =>\n this.options.renameFilename.call(this, file.name, file);\n }\n\n if (typeof this.options.method === \"string\") {\n this.options.method = this.options.method.toUpperCase();\n }\n\n if ((fallback = this.getExistingFallback()) && fallback.parentNode) {\n // Remove the fallback\n fallback.parentNode.removeChild(fallback);\n }\n\n // Display previews in the previewsContainer element or the Dropzone element unless explicitly set to false\n if (this.options.previewsContainer !== false) {\n if (this.options.previewsContainer) {\n this.previewsContainer = Dropzone.getElement(\n this.options.previewsContainer,\n \"previewsContainer\"\n );\n } else {\n this.previewsContainer = this.element;\n }\n }\n\n if (this.options.clickable) {\n if (this.options.clickable === true) {\n this.clickableElements = [this.element];\n } else {\n this.clickableElements = Dropzone.getElements(\n this.options.clickable,\n \"clickable\"\n );\n }\n }\n\n this.init();\n }\n\n // Returns all files that have been accepted\n getAcceptedFiles() {\n return this.files.filter((file) => file.accepted).map((file) => file);\n }\n\n // Returns all files that have been rejected\n // Not sure when that's going to be useful, but added for completeness.\n getRejectedFiles() {\n return this.files.filter((file) => !file.accepted).map((file) => file);\n }\n\n getFilesWithStatus(status) {\n return this.files\n .filter((file) => file.status === status)\n .map((file) => file);\n }\n\n // Returns all files that are in the queue\n getQueuedFiles() {\n return this.getFilesWithStatus(Dropzone.QUEUED);\n }\n\n getUploadingFiles() {\n return this.getFilesWithStatus(Dropzone.UPLOADING);\n }\n\n getAddedFiles() {\n return this.getFilesWithStatus(Dropzone.ADDED);\n }\n\n // Files that are either queued or uploading\n getActiveFiles() {\n return this.files\n .filter(\n (file) =>\n file.status === Dropzone.UPLOADING || file.status === Dropzone.QUEUED\n )\n .map((file) => file);\n }\n\n // The function that gets called when Dropzone is initialized. You\n // can (and should) setup event listeners inside this function.\n init() {\n // In case it isn't set already\n if (this.element.tagName === \"form\") {\n this.element.setAttribute(\"enctype\", \"multipart/form-data\");\n }\n\n if (\n this.element.classList.contains(\"dropzone\") &&\n !this.element.querySelector(\".dz-message\")\n ) {\n this.element.appendChild(\n Dropzone.createElement(\n ``\n )\n );\n }\n\n if (this.clickableElements.length) {\n let setupHiddenFileInput = () => {\n if (this.hiddenFileInput) {\n this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);\n }\n this.hiddenFileInput = document.createElement(\"input\");\n this.hiddenFileInput.setAttribute(\"type\", \"file\");\n if (this.options.maxFiles === null || this.options.maxFiles > 1) {\n this.hiddenFileInput.setAttribute(\"multiple\", \"multiple\");\n }\n this.hiddenFileInput.className = \"dz-hidden-input\";\n\n if (this.options.acceptedFiles !== null) {\n this.hiddenFileInput.setAttribute(\n \"accept\",\n this.options.acceptedFiles\n );\n }\n if (this.options.capture !== null) {\n this.hiddenFileInput.setAttribute(\"capture\", this.options.capture);\n }\n\n // Making sure that no one can \"tab\" into this field.\n this.hiddenFileInput.setAttribute(\"tabindex\", \"-1\");\n\n // Not setting `display=\"none\"` because some browsers don't accept clicks\n // on elements that aren't displayed.\n this.hiddenFileInput.style.visibility = \"hidden\";\n this.hiddenFileInput.style.position = \"absolute\";\n this.hiddenFileInput.style.top = \"0\";\n this.hiddenFileInput.style.left = \"0\";\n this.hiddenFileInput.style.height = \"0\";\n this.hiddenFileInput.style.width = \"0\";\n Dropzone.getElement(\n this.options.hiddenInputContainer,\n \"hiddenInputContainer\"\n ).appendChild(this.hiddenFileInput);\n this.hiddenFileInput.addEventListener(\"change\", () => {\n let { files } = this.hiddenFileInput;\n if (files.length) {\n for (let file of files) {\n this.addFile(file);\n }\n }\n this.emit(\"addedfiles\", files);\n setupHiddenFileInput();\n });\n };\n setupHiddenFileInput();\n }\n\n this.URL = window.URL !== null ? window.URL : window.webkitURL;\n\n // Setup all event listeners on the Dropzone object itself.\n // They're not in @setupEventListeners() because they shouldn't be removed\n // again when the dropzone gets disabled.\n for (let eventName of this.events) {\n this.on(eventName, this.options[eventName]);\n }\n\n this.on(\"uploadprogress\", () => this.updateTotalUploadProgress());\n\n this.on(\"removedfile\", () => this.updateTotalUploadProgress());\n\n this.on(\"canceled\", (file) => this.emit(\"complete\", file));\n\n // Emit a `queuecomplete` event if all files finished uploading.\n this.on(\"complete\", (file) => {\n if (\n this.getAddedFiles().length === 0 &&\n this.getUploadingFiles().length === 0 &&\n this.getQueuedFiles().length === 0\n ) {\n // This needs to be deferred so that `queuecomplete` really triggers after `complete`\n return setTimeout(() => this.emit(\"queuecomplete\"), 0);\n }\n });\n\n const containsFiles = function (e) {\n if (e.dataTransfer.types) {\n // Because e.dataTransfer.types is an Object in\n // IE, we need to iterate like this instead of\n // using e.dataTransfer.types.some()\n for (var i = 0; i < e.dataTransfer.types.length; i++) {\n if (e.dataTransfer.types[i] === \"Files\") return true;\n }\n }\n return false;\n };\n\n let noPropagation = function (e) {\n // If there are no files, we don't want to stop\n // propagation so we don't interfere with other\n // drag and drop behaviour.\n if (!containsFiles(e)) return;\n e.stopPropagation();\n if (e.preventDefault) {\n return e.preventDefault();\n } else {\n return (e.returnValue = false);\n }\n };\n\n // Create the listeners\n this.listeners = [\n {\n element: this.element,\n events: {\n dragstart: (e) => {\n return this.emit(\"dragstart\", e);\n },\n dragenter: (e) => {\n noPropagation(e);\n return this.emit(\"dragenter\", e);\n },\n dragover: (e) => {\n // Makes it possible to drag files from chrome's download bar\n // http://stackoverflow.com/questions/19526430/drag-and-drop-file-uploads-from-chrome-downloads-bar\n // Try is required to prevent bug in Internet Explorer 11 (SCRIPT65535 exception)\n let efct;\n try {\n efct = e.dataTransfer.effectAllowed;\n } catch (error) {}\n e.dataTransfer.dropEffect =\n \"move\" === efct || \"linkMove\" === efct ? \"move\" : \"copy\";\n\n noPropagation(e);\n return this.emit(\"dragover\", e);\n },\n dragleave: (e) => {\n return this.emit(\"dragleave\", e);\n },\n drop: (e) => {\n noPropagation(e);\n return this.drop(e);\n },\n dragend: (e) => {\n return this.emit(\"dragend\", e);\n },\n },\n\n // This is disabled right now, because the browsers don't implement it properly.\n // \"paste\": (e) =>\n // noPropagation e\n // @paste e\n },\n ];\n\n this.clickableElements.forEach((clickableElement) => {\n return this.listeners.push({\n element: clickableElement,\n events: {\n click: (evt) => {\n // Only the actual dropzone or the message element should trigger file selection\n if (\n clickableElement !== this.element ||\n evt.target === this.element ||\n Dropzone.elementInside(\n evt.target,\n this.element.querySelector(\".dz-message\")\n )\n ) {\n this.hiddenFileInput.click(); // Forward the click\n }\n return true;\n },\n },\n });\n });\n\n this.enable();\n\n return this.options.init.call(this);\n }\n\n // Not fully tested yet\n destroy() {\n this.disable();\n this.removeAllFiles(true);\n if (\n this.hiddenFileInput != null ? this.hiddenFileInput.parentNode : undefined\n ) {\n this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);\n this.hiddenFileInput = null;\n }\n delete this.element.dropzone;\n return Dropzone.instances.splice(Dropzone.instances.indexOf(this), 1);\n }\n\n updateTotalUploadProgress() {\n let totalUploadProgress;\n let totalBytesSent = 0;\n let totalBytes = 0;\n\n let activeFiles = this.getActiveFiles();\n\n if (activeFiles.length) {\n for (let file of this.getActiveFiles()) {\n totalBytesSent += file.upload.bytesSent;\n totalBytes += file.upload.total;\n }\n totalUploadProgress = (100 * totalBytesSent) / totalBytes;\n } else {\n totalUploadProgress = 100;\n }\n\n return this.emit(\n \"totaluploadprogress\",\n totalUploadProgress,\n totalBytes,\n totalBytesSent\n );\n }\n\n // @options.paramName can be a function taking one parameter rather than a string.\n // A parameter name for a file is obtained simply by calling this with an index number.\n _getParamName(n) {\n if (typeof this.options.paramName === \"function\") {\n return this.options.paramName(n);\n } else {\n return `${this.options.paramName}${\n this.options.uploadMultiple ? `[${n}]` : \"\"\n }`;\n }\n }\n\n // If @options.renameFile is a function,\n // the function will be used to rename the file.name before appending it to the formData\n _renameFile(file) {\n if (typeof this.options.renameFile !== \"function\") {\n return file.name;\n }\n return this.options.renameFile(file);\n }\n\n // Returns a form that can be used as fallback if the browser does not support DragnDrop\n //\n // If the dropzone is already a form, only the input field and button are returned. Otherwise a complete form element is provided.\n // This code has to pass in IE7 :(\n getFallbackForm() {\n let existingFallback, form;\n if ((existingFallback = this.getExistingFallback())) {\n return existingFallback;\n }\n\n let fieldsString = '
';\n if (this.options.dictFallbackText) {\n fieldsString += `
${this.options.dictFallbackText}
`;\n }\n fieldsString += `
`;\n\n let fields = Dropzone.createElement(fieldsString);\n if (this.element.tagName !== \"FORM\") {\n form = Dropzone.createElement(\n ``\n );\n form.appendChild(fields);\n } else {\n // Make sure that the enctype and method attributes are set properly\n this.element.setAttribute(\"enctype\", \"multipart/form-data\");\n this.element.setAttribute(\"method\", this.options.method);\n }\n return form != null ? form : fields;\n }\n\n // Returns the fallback elements if they exist already\n //\n // This code has to pass in IE7 :(\n getExistingFallback() {\n let getFallback = function (elements) {\n for (let el of elements) {\n if (/(^| )fallback($| )/.test(el.className)) {\n return el;\n }\n }\n };\n\n for (let tagName of [\"div\", \"form\"]) {\n var fallback;\n if (\n (fallback = getFallback(this.element.getElementsByTagName(tagName)))\n ) {\n return fallback;\n }\n }\n }\n\n // Activates all listeners stored in @listeners\n setupEventListeners() {\n return this.listeners.map((elementListeners) =>\n (() => {\n let result = [];\n for (let event in elementListeners.events) {\n let listener = elementListeners.events[event];\n result.push(\n elementListeners.element.addEventListener(event, listener, false)\n );\n }\n return result;\n })()\n );\n }\n\n // Deactivates all listeners stored in @listeners\n removeEventListeners() {\n return this.listeners.map((elementListeners) =>\n (() => {\n let result = [];\n for (let event in elementListeners.events) {\n let listener = elementListeners.events[event];\n result.push(\n elementListeners.element.removeEventListener(event, listener, false)\n );\n }\n return result;\n })()\n );\n }\n\n // Removes all event listeners and cancels all files in the queue or being processed.\n disable() {\n this.clickableElements.forEach((element) =>\n element.classList.remove(\"dz-clickable\")\n );\n this.removeEventListeners();\n this.disabled = true;\n\n return this.files.map((file) => this.cancelUpload(file));\n }\n\n enable() {\n delete this.disabled;\n this.clickableElements.forEach((element) =>\n element.classList.add(\"dz-clickable\")\n );\n return this.setupEventListeners();\n }\n\n // Returns a nicely formatted filesize\n filesize(size) {\n let selectedSize = 0;\n let selectedUnit = \"b\";\n\n if (size > 0) {\n let units = [\"tb\", \"gb\", \"mb\", \"kb\", \"b\"];\n\n for (let i = 0; i < units.length; i++) {\n let unit = units[i];\n let cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10;\n\n if (size >= cutoff) {\n selectedSize = size / Math.pow(this.options.filesizeBase, 4 - i);\n selectedUnit = unit;\n break;\n }\n }\n\n selectedSize = Math.round(10 * selectedSize) / 10; // Cutting of digits\n }\n\n return `${selectedSize} ${this.options.dictFileSizeUnits[selectedUnit]}`;\n }\n\n // Adds or removes the `dz-max-files-reached` class from the form.\n _updateMaxFilesReachedClass() {\n if (\n this.options.maxFiles != null &&\n this.getAcceptedFiles().length >= this.options.maxFiles\n ) {\n if (this.getAcceptedFiles().length === this.options.maxFiles) {\n this.emit(\"maxfilesreached\", this.files);\n }\n return this.element.classList.add(\"dz-max-files-reached\");\n } else {\n return this.element.classList.remove(\"dz-max-files-reached\");\n }\n }\n\n drop(e) {\n if (!e.dataTransfer) {\n return;\n }\n this.emit(\"drop\", e);\n\n // Convert the FileList to an Array\n // This is necessary for IE11\n let files = [];\n for (let i = 0; i < e.dataTransfer.files.length; i++) {\n files[i] = e.dataTransfer.files[i];\n }\n\n // Even if it's a folder, files.length will contain the folders.\n if (files.length) {\n let { items } = e.dataTransfer;\n if (items && items.length && items[0].webkitGetAsEntry != null) {\n // The browser supports dropping of folders, so handle items instead of files\n this._addFilesFromItems(items);\n } else {\n this.handleFiles(files);\n }\n }\n\n this.emit(\"addedfiles\", files);\n }\n\n paste(e) {\n if (\n __guard__(e != null ? e.clipboardData : undefined, (x) => x.items) == null\n ) {\n return;\n }\n\n this.emit(\"paste\", e);\n let { items } = e.clipboardData;\n\n if (items.length) {\n return this._addFilesFromItems(items);\n }\n }\n\n handleFiles(files) {\n for (let file of files) {\n this.addFile(file);\n }\n }\n\n // When a folder is dropped (or files are pasted), items must be handled\n // instead of files.\n _addFilesFromItems(items) {\n return (() => {\n let result = [];\n for (let item of items) {\n var entry;\n if (\n item.webkitGetAsEntry != null &&\n (entry = item.webkitGetAsEntry())\n ) {\n if (entry.isFile) {\n result.push(this.addFile(item.getAsFile()));\n } else if (entry.isDirectory) {\n // Append all files from that directory to files\n result.push(this._addFilesFromDirectory(entry, entry.name));\n } else {\n result.push(undefined);\n }\n } else if (item.getAsFile != null) {\n if (item.kind == null || item.kind === \"file\") {\n result.push(this.addFile(item.getAsFile()));\n } else {\n result.push(undefined);\n }\n } else {\n result.push(undefined);\n }\n }\n return result;\n })();\n }\n\n // Goes through the directory, and adds each file it finds recursively\n _addFilesFromDirectory(directory, path) {\n let dirReader = directory.createReader();\n\n let errorHandler = (error) =>\n __guardMethod__(console, \"log\", (o) => o.log(error));\n\n var readEntries = () => {\n return dirReader.readEntries((entries) => {\n if (entries.length > 0) {\n for (let entry of entries) {\n if (entry.isFile) {\n entry.file((file) => {\n if (\n this.options.ignoreHiddenFiles &&\n file.name.substring(0, 1) === \".\"\n ) {\n return;\n }\n file.fullPath = `${path}/${file.name}`;\n return this.addFile(file);\n });\n } else if (entry.isDirectory) {\n this._addFilesFromDirectory(entry, `${path}/${entry.name}`);\n }\n }\n\n // Recursively call readEntries() again, since browser only handle\n // the first 100 entries.\n // See: https://developer.mozilla.org/en-US/docs/Web/API/DirectoryReader#readEntries\n readEntries();\n }\n return null;\n }, errorHandler);\n };\n\n return readEntries();\n }\n\n // If `done()` is called without argument the file is accepted\n // If you call it with an error message, the file is rejected\n // (This allows for asynchronous validation)\n //\n // This function checks the filesize, and if the file.type passes the\n // `acceptedFiles` check.\n accept(file, done) {\n if (\n this.options.maxFilesize &&\n file.size > this.options.maxFilesize * 1024 * 1024\n ) {\n done(\n this.options.dictFileTooBig\n .replace(\"{{filesize}}\", Math.round(file.size / 1024 / 10.24) / 100)\n .replace(\"{{maxFilesize}}\", this.options.maxFilesize)\n );\n } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {\n done(this.options.dictInvalidFileType);\n } else if (\n this.options.maxFiles != null &&\n this.getAcceptedFiles().length >= this.options.maxFiles\n ) {\n done(\n this.options.dictMaxFilesExceeded.replace(\n \"{{maxFiles}}\",\n this.options.maxFiles\n )\n );\n this.emit(\"maxfilesexceeded\", file);\n } else {\n this.options.accept.call(this, file, done);\n }\n }\n\n addFile(file) {\n file.upload = {\n uuid: Dropzone.uuidv4(),\n progress: 0,\n // Setting the total upload size to file.size for the beginning\n // It's actual different than the size to be transmitted.\n total: file.size,\n bytesSent: 0,\n filename: this._renameFile(file),\n // Not setting chunking information here, because the acutal data — and\n // thus the chunks — might change if `options.transformFile` is set\n // and does something to the data.\n };\n this.files.push(file);\n\n file.status = Dropzone.ADDED;\n\n this.emit(\"addedfile\", file);\n\n this._enqueueThumbnail(file);\n\n this.accept(file, (error) => {\n if (error) {\n file.accepted = false;\n this._errorProcessing([file], error); // Will set the file.status\n } else {\n file.accepted = true;\n if (this.options.autoQueue) {\n this.enqueueFile(file);\n } // Will set .accepted = true\n }\n this._updateMaxFilesReachedClass();\n });\n }\n\n // Wrapper for enqueueFile\n enqueueFiles(files) {\n for (let file of files) {\n this.enqueueFile(file);\n }\n return null;\n }\n\n enqueueFile(file) {\n if (file.status === Dropzone.ADDED && file.accepted === true) {\n file.status = Dropzone.QUEUED;\n if (this.options.autoProcessQueue) {\n return setTimeout(() => this.processQueue(), 0); // Deferring the call\n }\n } else {\n throw new Error(\n \"This file can't be queued because it has already been processed or was rejected.\"\n );\n }\n }\n\n _enqueueThumbnail(file) {\n if (\n this.options.createImageThumbnails &&\n file.type.match(/image.*/) &&\n file.size <= this.options.maxThumbnailFilesize * 1024 * 1024\n ) {\n this._thumbnailQueue.push(file);\n return setTimeout(() => this._processThumbnailQueue(), 0); // Deferring the call\n }\n }\n\n _processThumbnailQueue() {\n if (this._processingThumbnail || this._thumbnailQueue.length === 0) {\n return;\n }\n\n this._processingThumbnail = true;\n let file = this._thumbnailQueue.shift();\n return this.createThumbnail(\n file,\n this.options.thumbnailWidth,\n this.options.thumbnailHeight,\n this.options.thumbnailMethod,\n true,\n (dataUrl) => {\n this.emit(\"thumbnail\", file, dataUrl);\n this._processingThumbnail = false;\n return this._processThumbnailQueue();\n }\n );\n }\n\n // Can be called by the user to remove a file\n removeFile(file) {\n if (file.status === Dropzone.UPLOADING) {\n this.cancelUpload(file);\n }\n this.files = without(this.files, file);\n\n this.emit(\"removedfile\", file);\n if (this.files.length === 0) {\n return this.emit(\"reset\");\n }\n }\n\n // Removes all files that aren't currently processed from the list\n removeAllFiles(cancelIfNecessary) {\n // Create a copy of files since removeFile() changes the @files array.\n if (cancelIfNecessary == null) {\n cancelIfNecessary = false;\n }\n for (let file of this.files.slice()) {\n if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) {\n this.removeFile(file);\n }\n }\n return null;\n }\n\n // Resizes an image before it gets sent to the server. This function is the default behavior of\n // `options.transformFile` if `resizeWidth` or `resizeHeight` are set. The callback is invoked with\n // the resized blob.\n resizeImage(file, width, height, resizeMethod, callback) {\n return this.createThumbnail(\n file,\n width,\n height,\n resizeMethod,\n true,\n (dataUrl, canvas) => {\n if (canvas == null) {\n // The image has not been resized\n return callback(file);\n } else {\n let { resizeMimeType } = this.options;\n if (resizeMimeType == null) {\n resizeMimeType = file.type;\n }\n let resizedDataURL = canvas.toDataURL(\n resizeMimeType,\n this.options.resizeQuality\n );\n if (\n resizeMimeType === \"image/jpeg\" ||\n resizeMimeType === \"image/jpg\"\n ) {\n // Now add the original EXIF information\n resizedDataURL = ExifRestore.restore(file.dataURL, resizedDataURL);\n }\n return callback(Dropzone.dataURItoBlob(resizedDataURL));\n }\n }\n );\n }\n\n createThumbnail(file, width, height, resizeMethod, fixOrientation, callback) {\n let fileReader = new FileReader();\n\n fileReader.onload = () => {\n file.dataURL = fileReader.result;\n\n // Don't bother creating a thumbnail for SVG images since they're vector\n if (file.type === \"image/svg+xml\") {\n if (callback != null) {\n callback(fileReader.result);\n }\n return;\n }\n\n this.createThumbnailFromUrl(\n file,\n width,\n height,\n resizeMethod,\n fixOrientation,\n callback\n );\n };\n\n fileReader.readAsDataURL(file);\n }\n\n // `mockFile` needs to have these attributes:\n //\n // { name: 'name', size: 12345, imageUrl: '' }\n //\n // `callback` will be invoked when the image has been downloaded and displayed.\n // `crossOrigin` will be added to the `img` tag when accessing the file.\n displayExistingFile(\n mockFile,\n imageUrl,\n callback,\n crossOrigin,\n resizeThumbnail = true\n ) {\n this.emit(\"addedfile\", mockFile);\n this.emit(\"complete\", mockFile);\n\n if (!resizeThumbnail) {\n this.emit(\"thumbnail\", mockFile, imageUrl);\n if (callback) callback();\n } else {\n let onDone = (thumbnail) => {\n this.emit(\"thumbnail\", mockFile, thumbnail);\n if (callback) callback();\n };\n mockFile.dataURL = imageUrl;\n\n this.createThumbnailFromUrl(\n mockFile,\n this.options.thumbnailWidth,\n this.options.thumbnailHeight,\n this.options.thumbnailMethod,\n this.options.fixOrientation,\n onDone,\n crossOrigin\n );\n }\n }\n\n createThumbnailFromUrl(\n file,\n width,\n height,\n resizeMethod,\n fixOrientation,\n callback,\n crossOrigin\n ) {\n // Not using `new Image` here because of a bug in latest Chrome versions.\n // See https://github.com/enyo/dropzone/pull/226\n let img = document.createElement(\"img\");\n\n if (crossOrigin) {\n img.crossOrigin = crossOrigin;\n }\n\n // fixOrientation is not needed anymore with browsers handling imageOrientation\n fixOrientation =\n getComputedStyle(document.body)[\"imageOrientation\"] == \"from-image\"\n ? false\n : fixOrientation;\n\n img.onload = () => {\n let loadExif = (callback) => callback(1);\n if (typeof EXIF !== \"undefined\" && EXIF !== null && fixOrientation) {\n loadExif = (callback) =>\n EXIF.getData(img, function () {\n return callback(EXIF.getTag(this, \"Orientation\"));\n });\n }\n\n return loadExif((orientation) => {\n file.width = img.width;\n file.height = img.height;\n\n let resizeInfo = this.options.resize.call(\n this,\n file,\n width,\n height,\n resizeMethod\n );\n\n let canvas = document.createElement(\"canvas\");\n let ctx = canvas.getContext(\"2d\");\n\n canvas.width = resizeInfo.trgWidth;\n canvas.height = resizeInfo.trgHeight;\n\n if (orientation > 4) {\n canvas.width = resizeInfo.trgHeight;\n canvas.height = resizeInfo.trgWidth;\n }\n\n switch (orientation) {\n case 2:\n // horizontal flip\n ctx.translate(canvas.width, 0);\n ctx.scale(-1, 1);\n break;\n case 3:\n // 180° rotate left\n ctx.translate(canvas.width, canvas.height);\n ctx.rotate(Math.PI);\n break;\n case 4:\n // vertical flip\n ctx.translate(0, canvas.height);\n ctx.scale(1, -1);\n break;\n case 5:\n // vertical flip + 90 rotate right\n ctx.rotate(0.5 * Math.PI);\n ctx.scale(1, -1);\n break;\n case 6:\n // 90° rotate right\n ctx.rotate(0.5 * Math.PI);\n ctx.translate(0, -canvas.width);\n break;\n case 7:\n // horizontal flip + 90 rotate right\n ctx.rotate(0.5 * Math.PI);\n ctx.translate(canvas.height, -canvas.width);\n ctx.scale(-1, 1);\n break;\n case 8:\n // 90° rotate left\n ctx.rotate(-0.5 * Math.PI);\n ctx.translate(-canvas.height, 0);\n break;\n }\n\n // This is a bugfix for iOS' scaling bug.\n drawImageIOSFix(\n ctx,\n img,\n resizeInfo.srcX != null ? resizeInfo.srcX : 0,\n resizeInfo.srcY != null ? resizeInfo.srcY : 0,\n resizeInfo.srcWidth,\n resizeInfo.srcHeight,\n resizeInfo.trgX != null ? resizeInfo.trgX : 0,\n resizeInfo.trgY != null ? resizeInfo.trgY : 0,\n resizeInfo.trgWidth,\n resizeInfo.trgHeight\n );\n\n let thumbnail = canvas.toDataURL(\"image/png\");\n\n if (callback != null) {\n return callback(thumbnail, canvas);\n }\n });\n };\n\n if (callback != null) {\n img.onerror = callback;\n }\n\n return (img.src = file.dataURL);\n }\n\n // Goes through the queue and processes files if there aren't too many already.\n processQueue() {\n let { parallelUploads } = this.options;\n let processingLength = this.getUploadingFiles().length;\n let i = processingLength;\n\n // There are already at least as many files uploading than should be\n if (processingLength >= parallelUploads) {\n return;\n }\n\n let queuedFiles = this.getQueuedFiles();\n\n if (!(queuedFiles.length > 0)) {\n return;\n }\n\n if (this.options.uploadMultiple) {\n // The files should be uploaded in one request\n return this.processFiles(\n queuedFiles.slice(0, parallelUploads - processingLength)\n );\n } else {\n while (i < parallelUploads) {\n if (!queuedFiles.length) {\n return;\n } // Nothing left to process\n this.processFile(queuedFiles.shift());\n i++;\n }\n }\n }\n\n // Wrapper for `processFiles`\n processFile(file) {\n return this.processFiles([file]);\n }\n\n // Loads the file, then calls finishedLoading()\n processFiles(files) {\n for (let file of files) {\n file.processing = true; // Backwards compatibility\n file.status = Dropzone.UPLOADING;\n\n this.emit(\"processing\", file);\n }\n\n if (this.options.uploadMultiple) {\n this.emit(\"processingmultiple\", files);\n }\n\n return this.uploadFiles(files);\n }\n\n _getFilesWithXhr(xhr) {\n let files;\n return (files = this.files\n .filter((file) => file.xhr === xhr)\n .map((file) => file));\n }\n\n // Cancels the file upload and sets the status to CANCELED\n // **if** the file is actually being uploaded.\n // If it's still in the queue, the file is being removed from it and the status\n // set to CANCELED.\n cancelUpload(file) {\n if (file.status === Dropzone.UPLOADING) {\n let groupedFiles = this._getFilesWithXhr(file.xhr);\n for (let groupedFile of groupedFiles) {\n groupedFile.status = Dropzone.CANCELED;\n }\n if (typeof file.xhr !== \"undefined\") {\n file.xhr.abort();\n }\n for (let groupedFile of groupedFiles) {\n this.emit(\"canceled\", groupedFile);\n }\n if (this.options.uploadMultiple) {\n this.emit(\"canceledmultiple\", groupedFiles);\n }\n } else if (\n file.status === Dropzone.ADDED ||\n file.status === Dropzone.QUEUED\n ) {\n file.status = Dropzone.CANCELED;\n this.emit(\"canceled\", file);\n if (this.options.uploadMultiple) {\n this.emit(\"canceledmultiple\", [file]);\n }\n }\n\n if (this.options.autoProcessQueue) {\n return this.processQueue();\n }\n }\n\n resolveOption(option, ...args) {\n if (typeof option === \"function\") {\n return option.apply(this, args);\n }\n return option;\n }\n\n uploadFile(file) {\n return this.uploadFiles([file]);\n }\n\n uploadFiles(files) {\n this._transformFiles(files, (transformedFiles) => {\n if (this.options.chunking) {\n // Chunking is not allowed to be used with `uploadMultiple` so we know\n // that there is only __one__file.\n let transformedFile = transformedFiles[0];\n files[0].upload.chunked =\n this.options.chunking &&\n (this.options.forceChunking ||\n transformedFile.size > this.options.chunkSize);\n files[0].upload.totalChunkCount = Math.ceil(\n transformedFile.size / this.options.chunkSize\n );\n }\n\n if (files[0].upload.chunked) {\n // This file should be sent in chunks!\n\n // If the chunking option is set, we **know** that there can only be **one** file, since\n // uploadMultiple is not allowed with this option.\n let file = files[0];\n let transformedFile = transformedFiles[0];\n let startedChunkCount = 0;\n\n file.upload.chunks = [];\n\n let handleNextChunk = () => {\n let chunkIndex = 0;\n\n // Find the next item in file.upload.chunks that is not defined yet.\n while (file.upload.chunks[chunkIndex] !== undefined) {\n chunkIndex++;\n }\n\n // This means, that all chunks have already been started.\n if (chunkIndex >= file.upload.totalChunkCount) return;\n\n startedChunkCount++;\n\n let start = chunkIndex * this.options.chunkSize;\n let end = Math.min(\n start + this.options.chunkSize,\n transformedFile.size\n );\n\n let dataBlock = {\n name: this._getParamName(0),\n data: transformedFile.webkitSlice\n ? transformedFile.webkitSlice(start, end)\n : transformedFile.slice(start, end),\n filename: file.upload.filename,\n chunkIndex: chunkIndex,\n };\n\n file.upload.chunks[chunkIndex] = {\n file: file,\n index: chunkIndex,\n dataBlock: dataBlock, // In case we want to retry.\n status: Dropzone.UPLOADING,\n progress: 0,\n retries: 0, // The number of times this block has been retried.\n };\n\n this._uploadData(files, [dataBlock]);\n };\n\n file.upload.finishedChunkUpload = (chunk, response) => {\n let allFinished = true;\n chunk.status = Dropzone.SUCCESS;\n\n // Clear the data from the chunk\n chunk.dataBlock = null;\n chunk.response = chunk.xhr.responseText;\n chunk.responseHeaders = chunk.xhr.getAllResponseHeaders();\n // Leaving this reference to xhr will cause memory leaks.\n chunk.xhr = null;\n\n for (let i = 0; i < file.upload.totalChunkCount; i++) {\n if (file.upload.chunks[i] === undefined) {\n return handleNextChunk();\n }\n if (file.upload.chunks[i].status !== Dropzone.SUCCESS) {\n allFinished = false;\n }\n }\n\n if (allFinished) {\n this.options.chunksUploaded(file, () => {\n this._finished(files, response, null);\n });\n }\n };\n\n if (this.options.parallelChunkUploads) {\n for (let i = 0; i < file.upload.totalChunkCount; i++) {\n handleNextChunk();\n }\n } else {\n handleNextChunk();\n }\n } else {\n let dataBlocks = [];\n for (let i = 0; i < files.length; i++) {\n dataBlocks[i] = {\n name: this._getParamName(i),\n data: transformedFiles[i],\n filename: files[i].upload.filename,\n };\n }\n this._uploadData(files, dataBlocks);\n }\n });\n }\n\n /// Returns the right chunk for given file and xhr\n _getChunk(file, xhr) {\n for (let i = 0; i < file.upload.totalChunkCount; i++) {\n if (\n file.upload.chunks[i] !== undefined &&\n file.upload.chunks[i].xhr === xhr\n ) {\n return file.upload.chunks[i];\n }\n }\n }\n\n // This function actually uploads the file(s) to the server.\n //\n // If dataBlocks contains the actual data to upload (meaning, that this could\n // either be transformed files, or individual chunks for chunked upload) then\n // they will be used for the actual data to upload.\n _uploadData(files, dataBlocks) {\n let xhr = new XMLHttpRequest();\n\n // Put the xhr object in the file objects to be able to reference it later.\n for (let file of files) {\n file.xhr = xhr;\n }\n if (files[0].upload.chunked) {\n // Put the xhr object in the right chunk object, so it can be associated\n // later, and found with _getChunk.\n files[0].upload.chunks[dataBlocks[0].chunkIndex].xhr = xhr;\n }\n\n let method = this.resolveOption(this.options.method, files, dataBlocks);\n let url = this.resolveOption(this.options.url, files, dataBlocks);\n xhr.open(method, url, true);\n\n // Setting the timeout after open because of IE11 issue: https://gitlab.com/meno/dropzone/issues/8\n let timeout = this.resolveOption(this.options.timeout, files);\n if (timeout) xhr.timeout = this.resolveOption(this.options.timeout, files);\n\n // Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179\n xhr.withCredentials = !!this.options.withCredentials;\n\n xhr.onload = (e) => {\n this._finishedUploading(files, xhr, e);\n };\n\n xhr.ontimeout = () => {\n this._handleUploadError(\n files,\n xhr,\n `Request timedout after ${this.options.timeout / 1000} seconds`\n );\n };\n\n xhr.onerror = () => {\n this._handleUploadError(files, xhr);\n };\n\n // Some browsers do not have the .upload property\n let progressObj = xhr.upload != null ? xhr.upload : xhr;\n progressObj.onprogress = (e) =>\n this._updateFilesUploadProgress(files, xhr, e);\n\n let headers = this.options.defaultHeaders\n ? {\n Accept: \"application/json\",\n \"Cache-Control\": \"no-cache\",\n \"X-Requested-With\": \"XMLHttpRequest\",\n }\n : {};\n\n if (this.options.binaryBody) {\n headers[\"Content-Type\"] = files[0].type;\n }\n\n if (this.options.headers) {\n extend(headers, this.options.headers);\n }\n\n for (let headerName in headers) {\n let headerValue = headers[headerName];\n if (headerValue) {\n xhr.setRequestHeader(headerName, headerValue);\n }\n }\n\n if (this.options.binaryBody) {\n // Since the file is going to be sent as binary body, it doesn't make\n // any sense to generate `FormData` for it.\n for (let file of files) {\n this.emit(\"sending\", file, xhr);\n }\n if (this.options.uploadMultiple) {\n this.emit(\"sendingmultiple\", files, xhr);\n }\n this.submitRequest(xhr, null, files);\n } else {\n let formData = new FormData();\n\n // Adding all @options parameters\n if (this.options.params) {\n let additionalParams = this.options.params;\n if (typeof additionalParams === \"function\") {\n additionalParams = additionalParams.call(\n this,\n files,\n xhr,\n files[0].upload.chunked ? this._getChunk(files[0], xhr) : null\n );\n }\n\n for (let key in additionalParams) {\n let value = additionalParams[key];\n if (Array.isArray(value)) {\n // The additional parameter contains an array,\n // so lets iterate over it to attach each value\n // individually.\n for (let i = 0; i < value.length; i++) {\n formData.append(key, value[i]);\n }\n } else {\n formData.append(key, value);\n }\n }\n }\n\n // Let the user add additional data if necessary\n for (let file of files) {\n this.emit(\"sending\", file, xhr, formData);\n }\n if (this.options.uploadMultiple) {\n this.emit(\"sendingmultiple\", files, xhr, formData);\n }\n\n this._addFormElementData(formData);\n\n // Finally add the files\n // Has to be last because some servers (eg: S3) expect the file to be the last parameter\n for (let i = 0; i < dataBlocks.length; i++) {\n let dataBlock = dataBlocks[i];\n formData.append(dataBlock.name, dataBlock.data, dataBlock.filename);\n }\n\n this.submitRequest(xhr, formData, files);\n }\n }\n\n // Transforms all files with this.options.transformFile and invokes done with the transformed files when done.\n _transformFiles(files, done) {\n let transformedFiles = [];\n // Clumsy way of handling asynchronous calls, until I get to add a proper Future library.\n let doneCounter = 0;\n for (let i = 0; i < files.length; i++) {\n this.options.transformFile.call(this, files[i], (transformedFile) => {\n transformedFiles[i] = transformedFile;\n if (++doneCounter === files.length) {\n done(transformedFiles);\n }\n });\n }\n }\n\n // Takes care of adding other input elements of the form to the AJAX request\n _addFormElementData(formData) {\n // Take care of other input elements\n if (this.element.tagName === \"FORM\") {\n for (let input of this.element.querySelectorAll(\n \"input, textarea, select, button\"\n )) {\n let inputName = input.getAttribute(\"name\");\n let inputType = input.getAttribute(\"type\");\n if (inputType) inputType = inputType.toLowerCase();\n\n // If the input doesn't have a name, we can't use it.\n if (typeof inputName === \"undefined\" || inputName === null) continue;\n\n if (input.tagName === \"SELECT\" && input.hasAttribute(\"multiple\")) {\n // Possibly multiple values\n for (let option of input.options) {\n if (option.selected) {\n formData.append(inputName, option.value);\n }\n }\n } else if (\n !inputType ||\n (inputType !== \"checkbox\" && inputType !== \"radio\") ||\n input.checked\n ) {\n formData.append(inputName, input.value);\n }\n }\n }\n }\n\n // Invoked when there is new progress information about given files.\n // If e is not provided, it is assumed that the upload is finished.\n _updateFilesUploadProgress(files, xhr, e) {\n if (!files[0].upload.chunked) {\n // Handle file uploads without chunking\n for (let file of files) {\n if (\n file.upload.total &&\n file.upload.bytesSent &&\n file.upload.bytesSent == file.upload.total\n ) {\n // If both, the `total` and `bytesSent` have already been set, and\n // they are equal (meaning progress is at 100%), we can skip this\n // file, since an upload progress shouldn't go down.\n continue;\n }\n\n if (e) {\n file.upload.progress = (100 * e.loaded) / e.total;\n file.upload.total = e.total;\n file.upload.bytesSent = e.loaded;\n } else {\n // No event, so we're at 100%\n file.upload.progress = 100;\n file.upload.bytesSent = file.upload.total;\n }\n\n this.emit(\n \"uploadprogress\",\n file,\n file.upload.progress,\n file.upload.bytesSent\n );\n }\n } else {\n // Handle chunked file uploads\n\n // Chunked upload is not compatible with uploading multiple files in one\n // request, so we know there's only one file.\n let file = files[0];\n\n // Since this is a chunked upload, we need to update the appropriate chunk\n // progress.\n let chunk = this._getChunk(file, xhr);\n\n if (e) {\n chunk.progress = (100 * e.loaded) / e.total;\n chunk.total = e.total;\n chunk.bytesSent = e.loaded;\n } else {\n // No event, so we're at 100%\n chunk.progress = 100;\n chunk.bytesSent = chunk.total;\n }\n\n // Now tally the *file* upload progress from its individual chunks\n file.upload.progress = 0;\n file.upload.total = 0;\n file.upload.bytesSent = 0;\n for (let i = 0; i < file.upload.totalChunkCount; i++) {\n if (\n file.upload.chunks[i] &&\n typeof file.upload.chunks[i].progress !== \"undefined\"\n ) {\n file.upload.progress += file.upload.chunks[i].progress;\n file.upload.total += file.upload.chunks[i].total;\n file.upload.bytesSent += file.upload.chunks[i].bytesSent;\n }\n }\n // Since the process is a percentage, we need to divide by the amount of\n // chunks we've used.\n file.upload.progress = file.upload.progress / file.upload.totalChunkCount;\n\n this.emit(\n \"uploadprogress\",\n file,\n file.upload.progress,\n file.upload.bytesSent\n );\n }\n }\n\n _finishedUploading(files, xhr, e) {\n let response;\n\n if (files[0].status === Dropzone.CANCELED) {\n return;\n }\n\n if (xhr.readyState !== 4) {\n return;\n }\n\n if (xhr.responseType !== \"arraybuffer\" && xhr.responseType !== \"blob\") {\n response = xhr.responseText;\n\n if (\n xhr.getResponseHeader(\"content-type\") &&\n ~xhr.getResponseHeader(\"content-type\").indexOf(\"application/json\")\n ) {\n try {\n response = JSON.parse(response);\n } catch (error) {\n e = error;\n response = \"Invalid JSON response from server.\";\n }\n }\n }\n\n this._updateFilesUploadProgress(files, xhr);\n\n if (!(200 <= xhr.status && xhr.status < 300)) {\n this._handleUploadError(files, xhr, response);\n } else {\n if (files[0].upload.chunked) {\n files[0].upload.finishedChunkUpload(\n this._getChunk(files[0], xhr),\n response\n );\n } else {\n this._finished(files, response, e);\n }\n }\n }\n\n _handleUploadError(files, xhr, response) {\n if (files[0].status === Dropzone.CANCELED) {\n return;\n }\n\n if (files[0].upload.chunked && this.options.retryChunks) {\n let chunk = this._getChunk(files[0], xhr);\n if (chunk.retries++ < this.options.retryChunksLimit) {\n this._uploadData(files, [chunk.dataBlock]);\n return;\n } else {\n console.warn(\"Retried this chunk too often. Giving up.\");\n }\n }\n\n this._errorProcessing(\n files,\n response ||\n this.options.dictResponseError.replace(\"{{statusCode}}\", xhr.status),\n xhr\n );\n }\n\n submitRequest(xhr, formData, files) {\n if (xhr.readyState != 1) {\n console.warn(\n \"Cannot send this request because the XMLHttpRequest.readyState is not OPENED.\"\n );\n return;\n }\n if (this.options.binaryBody) {\n if (files[0].upload.chunked) {\n const chunk = this._getChunk(files[0], xhr);\n xhr.send(chunk.dataBlock.data);\n } else {\n xhr.send(files[0]);\n }\n } else {\n xhr.send(formData);\n }\n }\n\n // Called internally when processing is finished.\n // Individual callbacks have to be called in the appropriate sections.\n _finished(files, responseText, e) {\n for (let file of files) {\n file.status = Dropzone.SUCCESS;\n this.emit(\"success\", file, responseText, e);\n this.emit(\"complete\", file);\n }\n if (this.options.uploadMultiple) {\n this.emit(\"successmultiple\", files, responseText, e);\n this.emit(\"completemultiple\", files);\n }\n\n if (this.options.autoProcessQueue) {\n return this.processQueue();\n }\n }\n\n // Called internally when processing is finished.\n // Individual callbacks have to be called in the appropriate sections.\n _errorProcessing(files, message, xhr) {\n for (let file of files) {\n file.status = Dropzone.ERROR;\n this.emit(\"error\", file, message, xhr);\n this.emit(\"complete\", file);\n }\n if (this.options.uploadMultiple) {\n this.emit(\"errormultiple\", files, message, xhr);\n this.emit(\"completemultiple\", files);\n }\n\n if (this.options.autoProcessQueue) {\n return this.processQueue();\n }\n }\n\n static uuidv4() {\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(\n /[xy]/g,\n function (c) {\n let r = (Math.random() * 16) | 0,\n v = c === \"x\" ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n }\n );\n }\n}\nDropzone.initClass();\n\n// This is a map of options for your different dropzones. Add configurations\n// to this object for your different dropzone elemens.\n//\n// Example:\n//\n// Dropzone.options.myDropzoneElementId = { maxFilesize: 1 };\n//\n// And in html:\n//\n// \nDropzone.options = {};\n\n// Returns the options for an element or undefined if none available.\nDropzone.optionsForElement = function (element) {\n // Get the `Dropzone.options.elementId` for this element if it exists\n if (element.getAttribute(\"id\")) {\n return Dropzone.options[camelize(element.getAttribute(\"id\"))];\n } else {\n return undefined;\n }\n};\n\n// Holds a list of all dropzone instances\nDropzone.instances = [];\n\n// Returns the dropzone for given element if any\nDropzone.forElement = function (element) {\n if (typeof element === \"string\") {\n element = document.querySelector(element);\n }\n if ((element != null ? element.dropzone : undefined) == null) {\n throw new Error(\n \"No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.\"\n );\n }\n return element.dropzone;\n};\n\n// Looks for all .dropzone elements and creates a dropzone for them\nDropzone.discover = function () {\n let dropzones;\n if (document.querySelectorAll) {\n dropzones = document.querySelectorAll(\".dropzone\");\n } else {\n dropzones = [];\n // IE :(\n let checkElements = (elements) =>\n (() => {\n let result = [];\n for (let el of elements) {\n if (/(^| )dropzone($| )/.test(el.className)) {\n result.push(dropzones.push(el));\n } else {\n result.push(undefined);\n }\n }\n return result;\n })();\n checkElements(document.getElementsByTagName(\"div\"));\n checkElements(document.getElementsByTagName(\"form\"));\n }\n\n return (() => {\n let result = [];\n for (let dropzone of dropzones) {\n // Create a dropzone unless auto discover has been disabled for specific element\n if (Dropzone.optionsForElement(dropzone) !== false) {\n result.push(new Dropzone(dropzone));\n } else {\n result.push(undefined);\n }\n }\n return result;\n })();\n};\n\n// Some browsers support drag and drog functionality, but not correctly.\n//\n// So I created a blocklist of userAgents. Yes, yes. Browser sniffing, I know.\n// But what to do when browsers *theoretically* support an API, but crash\n// when using it.\n//\n// This is a list of regular expressions tested against navigator.userAgent\n//\n// ** It should only be used on browser that *do* support the API, but\n// incorrectly **\nDropzone.blockedBrowsers = [\n // The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.\n /opera.*(Macintosh|Windows Phone).*version\\/12/i,\n];\n\n// Checks if the browser is supported\nDropzone.isBrowserSupported = function () {\n let capableBrowser = true;\n\n if (\n window.File &&\n window.FileReader &&\n window.FileList &&\n window.Blob &&\n window.FormData &&\n document.querySelector\n ) {\n if (!(\"classList\" in document.createElement(\"a\"))) {\n capableBrowser = false;\n } else {\n if (Dropzone.blacklistedBrowsers !== undefined) {\n // Since this has been renamed, this makes sure we don't break older\n // configuration.\n Dropzone.blockedBrowsers = Dropzone.blacklistedBrowsers;\n }\n // The browser supports the API, but may be blocked.\n for (let regex of Dropzone.blockedBrowsers) {\n if (regex.test(navigator.userAgent)) {\n capableBrowser = false;\n continue;\n }\n }\n }\n } else {\n capableBrowser = false;\n }\n\n return capableBrowser;\n};\n\nDropzone.dataURItoBlob = function (dataURI) {\n // convert base64 to raw binary data held in a string\n // doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this\n let byteString = atob(dataURI.split(\",\")[1]);\n\n // separate out the mime component\n let mimeString = dataURI.split(\",\")[0].split(\":\")[1].split(\";\")[0];\n\n // write the bytes of the string to an ArrayBuffer\n let ab = new ArrayBuffer(byteString.length);\n let ia = new Uint8Array(ab);\n for (\n let i = 0, end = byteString.length, asc = 0 <= end;\n asc ? i <= end : i >= end;\n asc ? i++ : i--\n ) {\n ia[i] = byteString.charCodeAt(i);\n }\n\n // write the ArrayBuffer to a blob\n return new Blob([ab], { type: mimeString });\n};\n\n// Returns an array without the rejected item\nconst without = (list, rejectedItem) =>\n list.filter((item) => item !== rejectedItem).map((item) => item);\n\n// abc-def_ghi -> abcDefGhi\nconst camelize = (str) =>\n str.replace(/[\\-_](\\w)/g, (match) => match.charAt(1).toUpperCase());\n\n// Creates an element from string\nDropzone.createElement = function (string) {\n let div = document.createElement(\"div\");\n div.innerHTML = string;\n return div.childNodes[0];\n};\n\n// Tests if given element is inside (or simply is) the container\nDropzone.elementInside = function (element, container) {\n if (element === container) {\n return true;\n } // Coffeescript doesn't support do/while loops\n while ((element = element.parentNode)) {\n if (element === container) {\n return true;\n }\n }\n return false;\n};\n\nDropzone.getElement = function (el, name) {\n let element;\n if (typeof el === \"string\") {\n element = document.querySelector(el);\n } else if (el.nodeType != null) {\n element = el;\n }\n if (element == null) {\n throw new Error(\n `Invalid \\`${name}\\` option provided. Please provide a CSS selector or a plain HTML element.`\n );\n }\n return element;\n};\n\nDropzone.getElements = function (els, name) {\n let el, elements;\n if (els instanceof Array) {\n elements = [];\n try {\n for (el of els) {\n elements.push(this.getElement(el, name));\n }\n } catch (e) {\n elements = null;\n }\n } else if (typeof els === \"string\") {\n elements = [];\n for (el of document.querySelectorAll(els)) {\n elements.push(el);\n }\n } else if (els.nodeType != null) {\n elements = [els];\n }\n\n if (elements == null || !elements.length) {\n throw new Error(\n `Invalid \\`${name}\\` option provided. Please provide a CSS selector, a plain HTML element or a list of those.`\n );\n }\n\n return elements;\n};\n\n// Asks the user the question and calls accepted or rejected accordingly\n//\n// The default implementation just uses `window.confirm` and then calls the\n// appropriate callback.\nDropzone.confirm = function (question, accepted, rejected) {\n if (window.confirm(question)) {\n return accepted();\n } else if (rejected != null) {\n return rejected();\n }\n};\n\n// Validates the mime type like this:\n//\n// https://developer.mozilla.org/en-US/docs/HTML/Element/input#attr-accept\nDropzone.isValidFile = function (file, acceptedFiles) {\n if (!acceptedFiles) {\n return true;\n } // If there are no accepted mime types, it's OK\n acceptedFiles = acceptedFiles.split(\",\");\n\n let mimeType = file.type;\n let baseMimeType = mimeType.replace(/\\/.*$/, \"\");\n\n for (let validType of acceptedFiles) {\n validType = validType.trim();\n if (validType.charAt(0) === \".\") {\n if (\n file.name\n .toLowerCase()\n .indexOf(\n validType.toLowerCase(),\n file.name.length - validType.length\n ) !== -1\n ) {\n return true;\n }\n } else if (/\\/\\*$/.test(validType)) {\n // This is something like a image/* mime type\n if (baseMimeType === validType.replace(/\\/.*$/, \"\")) {\n return true;\n }\n } else {\n if (mimeType === validType) {\n return true;\n }\n }\n }\n\n return false;\n};\n\n// Augment jQuery\nif (typeof jQuery !== \"undefined\" && jQuery !== null) {\n jQuery.fn.dropzone = function (options) {\n return this.each(function () {\n return new Dropzone(this, options);\n });\n };\n}\n\n// Dropzone file status codes\nDropzone.ADDED = \"added\";\n\nDropzone.QUEUED = \"queued\";\n// For backwards compatibility. Now, if a file is accepted, it's either queued\n// or uploading.\nDropzone.ACCEPTED = Dropzone.QUEUED;\n\nDropzone.UPLOADING = \"uploading\";\nDropzone.PROCESSING = Dropzone.UPLOADING; // alias\n\nDropzone.CANCELED = \"canceled\";\nDropzone.ERROR = \"error\";\nDropzone.SUCCESS = \"success\";\n\n/*\n\n Bugfix for iOS 6 and 7\n Source: http://stackoverflow.com/questions/11929099/html5-canvas-drawimage-ratio-bug-ios\n based on the work of https://github.com/stomita/ios-imagefile-megapixel\n\n */\n\n// Detecting vertical squash in loaded image.\n// Fixes a bug which squash image vertically while drawing into canvas for some images.\n// This is a bug in iOS6 devices. This function from https://github.com/stomita/ios-imagefile-megapixel\nlet detectVerticalSquash = function (img) {\n let iw = img.naturalWidth;\n let ih = img.naturalHeight;\n let canvas = document.createElement(\"canvas\");\n canvas.width = 1;\n canvas.height = ih;\n let ctx = canvas.getContext(\"2d\");\n ctx.drawImage(img, 0, 0);\n let { data } = ctx.getImageData(1, 0, 1, ih);\n\n // search image edge pixel position in case it is squashed vertically.\n let sy = 0;\n let ey = ih;\n let py = ih;\n while (py > sy) {\n let alpha = data[(py - 1) * 4 + 3];\n\n if (alpha === 0) {\n ey = py;\n } else {\n sy = py;\n }\n\n py = (ey + sy) >> 1;\n }\n let ratio = py / ih;\n\n if (ratio === 0) {\n return 1;\n } else {\n return ratio;\n }\n};\n\n// A replacement for context.drawImage\n// (args are for source and destination).\nvar drawImageIOSFix = function (ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) {\n let vertSquashRatio = detectVerticalSquash(img);\n return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio);\n};\n\n// Based on MinifyJpeg\n// Source: http://www.perry.cz/files/ExifRestorer.js\n// http://elicon.blog57.fc2.com/blog-entry-206.html\nclass ExifRestore {\n static initClass() {\n this.KEY_STR =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n }\n\n static encode64(input) {\n let output = \"\";\n let chr1 = undefined;\n let chr2 = undefined;\n let chr3 = \"\";\n let enc1 = undefined;\n let enc2 = undefined;\n let enc3 = undefined;\n let enc4 = \"\";\n let i = 0;\n while (true) {\n chr1 = input[i++];\n chr2 = input[i++];\n chr3 = input[i++];\n enc1 = chr1 >> 2;\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\n enc4 = chr3 & 63;\n if (isNaN(chr2)) {\n enc3 = enc4 = 64;\n } else if (isNaN(chr3)) {\n enc4 = 64;\n }\n output =\n output +\n this.KEY_STR.charAt(enc1) +\n this.KEY_STR.charAt(enc2) +\n this.KEY_STR.charAt(enc3) +\n this.KEY_STR.charAt(enc4);\n chr1 = chr2 = chr3 = \"\";\n enc1 = enc2 = enc3 = enc4 = \"\";\n if (!(i < input.length)) {\n break;\n }\n }\n return output;\n }\n\n static restore(origFileBase64, resizedFileBase64) {\n if (!origFileBase64.match(\"data:image/jpeg;base64,\")) {\n return resizedFileBase64;\n }\n let rawImage = this.decode64(\n origFileBase64.replace(\"data:image/jpeg;base64,\", \"\")\n );\n let segments = this.slice2Segments(rawImage);\n let image = this.exifManipulation(resizedFileBase64, segments);\n return `data:image/jpeg;base64,${this.encode64(image)}`;\n }\n\n static exifManipulation(resizedFileBase64, segments) {\n let exifArray = this.getExifArray(segments);\n let newImageArray = this.insertExif(resizedFileBase64, exifArray);\n let aBuffer = new Uint8Array(newImageArray);\n return aBuffer;\n }\n\n static getExifArray(segments) {\n let seg = undefined;\n let x = 0;\n while (x < segments.length) {\n seg = segments[x];\n if ((seg[0] === 255) & (seg[1] === 225)) {\n return seg;\n }\n x++;\n }\n return [];\n }\n\n static insertExif(resizedFileBase64, exifArray) {\n let imageData = resizedFileBase64.replace(\"data:image/jpeg;base64,\", \"\");\n let buf = this.decode64(imageData);\n let separatePoint = buf.indexOf(255, 3);\n let mae = buf.slice(0, separatePoint);\n let ato = buf.slice(separatePoint);\n let array = mae;\n array = array.concat(exifArray);\n array = array.concat(ato);\n return array;\n }\n\n static slice2Segments(rawImageArray) {\n let head = 0;\n let segments = [];\n while (true) {\n var length;\n if ((rawImageArray[head] === 255) & (rawImageArray[head + 1] === 218)) {\n break;\n }\n if ((rawImageArray[head] === 255) & (rawImageArray[head + 1] === 216)) {\n head += 2;\n } else {\n length = rawImageArray[head + 2] * 256 + rawImageArray[head + 3];\n let endPoint = head + length + 2;\n let seg = rawImageArray.slice(head, endPoint);\n segments.push(seg);\n head = endPoint;\n }\n if (head > rawImageArray.length) {\n break;\n }\n }\n return segments;\n }\n\n static decode64(input) {\n let output = \"\";\n let chr1 = undefined;\n let chr2 = undefined;\n let chr3 = \"\";\n let enc1 = undefined;\n let enc2 = undefined;\n let enc3 = undefined;\n let enc4 = \"\";\n let i = 0;\n let buf = [];\n // remove all characters that are not A-Z, a-z, 0-9, +, /, or =\n let base64test = /[^A-Za-z0-9\\+\\/\\=]/g;\n if (base64test.exec(input)) {\n console.warn(\n \"There were invalid base64 characters in the input text.\\nValid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\\nExpect errors in decoding.\"\n );\n }\n input = input.replace(/[^A-Za-z0-9\\+\\/\\=]/g, \"\");\n while (true) {\n enc1 = this.KEY_STR.indexOf(input.charAt(i++));\n enc2 = this.KEY_STR.indexOf(input.charAt(i++));\n enc3 = this.KEY_STR.indexOf(input.charAt(i++));\n enc4 = this.KEY_STR.indexOf(input.charAt(i++));\n chr1 = (enc1 << 2) | (enc2 >> 4);\n chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);\n chr3 = ((enc3 & 3) << 6) | enc4;\n buf.push(chr1);\n if (enc3 !== 64) {\n buf.push(chr2);\n }\n if (enc4 !== 64) {\n buf.push(chr3);\n }\n chr1 = chr2 = chr3 = \"\";\n enc1 = enc2 = enc3 = enc4 = \"\";\n if (!(i < input.length)) {\n break;\n }\n }\n return buf;\n }\n}\nExifRestore.initClass();\n\n/*\n * contentloaded.js\n *\n * Author: Diego Perini (diego.perini at gmail.com)\n * Summary: cross-browser wrapper for DOMContentLoaded\n * Updated: 20101020\n * License: MIT\n * Version: 1.2\n *\n * URL:\n * http://javascript.nwbox.com/ContentLoaded/\n * http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE\n */\n\n// @win window reference\n// @fn function reference\nlet contentLoaded = function (win, fn) {\n let done = false;\n let top = true;\n let doc = win.document;\n let root = doc.documentElement;\n let add = doc.addEventListener ? \"addEventListener\" : \"attachEvent\";\n let rem = doc.addEventListener ? \"removeEventListener\" : \"detachEvent\";\n let pre = doc.addEventListener ? \"\" : \"on\";\n var init = function (e) {\n if (e.type === \"readystatechange\" && doc.readyState !== \"complete\") {\n return;\n }\n (e.type === \"load\" ? win : doc)[rem](pre + e.type, init, false);\n if (!done && (done = true)) {\n return fn.call(win, e.type || e);\n }\n };\n\n var poll = function () {\n try {\n root.doScroll(\"left\");\n } catch (e) {\n setTimeout(poll, 50);\n return;\n }\n return init(\"poll\");\n };\n\n if (doc.readyState !== \"complete\") {\n if (doc.createEventObject && root.doScroll) {\n try {\n top = !win.frameElement;\n } catch (error) {}\n if (top) {\n poll();\n }\n }\n doc[add](pre + \"DOMContentLoaded\", init, false);\n doc[add](pre + \"readystatechange\", init, false);\n return win[add](pre + \"load\", init, false);\n }\n};\n\nfunction __guard__(value, transform) {\n return typeof value !== \"undefined\" && value !== null\n ? transform(value)\n : undefined;\n}\nfunction __guardMethod__(obj, methodName, transform) {\n if (\n typeof obj !== \"undefined\" &&\n obj !== null &&\n typeof obj[methodName] === \"function\"\n ) {\n return transform(obj, methodName);\n } else {\n return undefined;\n }\n}\n\nexport { Dropzone };\n","import Dropzone from \"../src/dropzone\";\n\nwindow.Dropzone = Dropzone;\n\nexport default Dropzone;\n"],"names":["self","ReferenceError","instance","Constructor","TypeError","$068d7638c7686533$var$_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","protoProps","staticProps","prototype","$da42839ea2c5b431$var$getPrototypeOf","o","setPrototypeOf","getPrototypeOf","__proto__","$636ee2f214a98c8f$var$setPrototypeOf","p","subClass","superClass","create","constructor","value","call","obj","Symbol","$cf4679e12ceee72e$export$2e2bcd8739ae039","$114dff7b9008f5c0$var$isCloneable","Array","isArray","toString","$114dff7b9008f5c0$var$isUnextendable","val","$114dff7b9008f5c0$exports","$114dff7b9008f5c0$var$extend","args","slice","arguments","deep","shift","result","Error","extenders","len","extender","hasOwnProperty","base","$a527f8347b4b94dc$export$2e2bcd8739ae039","event","fn","this","_callbacks","push","_len","_key","callbacks","_iteratorNormalCompletion","_didIteratorError","_iteratorError","undefined","_step","_iterator","iterator","next","done","callback","apply","err","return","element","dispatchEvent","makeEvent","eventName","detail","params","bubbles","cancelable","window","CustomEvent","evt","document","createEvent","initCustomEvent","splice","$588a9ad8284f77de$export$2e2bcd8739ae039","url","method","withCredentials","timeout","parallelUploads","uploadMultiple","chunking","forceChunking","chunkSize","parallelChunkUploads","retryChunks","retryChunksLimit","maxFilesize","paramName","createImageThumbnails","maxThumbnailFilesize","thumbnailWidth","thumbnailHeight","thumbnailMethod","resizeWidth","resizeHeight","resizeMimeType","resizeQuality","resizeMethod","filesizeBase","maxFiles","headers","defaultHeaders","clickable","ignoreHiddenFiles","acceptedFiles","acceptedMimeTypes","autoProcessQueue","autoQueue","addRemoveLinks","previewsContainer","disablePreviews","hiddenInputContainer","capture","renameFilename","renameFile","forceFallback","dictDefaultMessage","dictFallbackMessage","dictFallbackText","dictFileTooBig","dictInvalidFileType","dictResponseError","dictCancelUpload","dictUploadCanceled","dictCancelUploadConfirmation","dictRemoveFile","dictRemoveFileConfirmation","dictMaxFilesExceeded","dictFileSizeUnits","tb","gb","mb","kb","b","init","files","xhr","chunk","dzuuid","file","upload","uuid","dzchunkindex","index","dztotalfilesize","size","dzchunksize","options","dztotalchunkcount","totalChunkCount","dzchunkbyteoffset","accept","chunksUploaded","binaryBody","fallback","messageElement","className","concat","getElementsByTagName","child","test","$0b112e5f3be94b9d$export$2e2bcd8739ae039","createElement","appendChild","span","textContent","innerText","getFallbackForm","resize","width","height","info","srcX","srcY","srcWidth","srcHeight","srcRatio","trgRatio","Math","min","trgWidth","trgHeight","transformFile","type","match","resizeImage","previewTemplate","$parcel$interopDefault","drop","e","classList","remove","dragstart","dragend","dragenter","add","dragover","dragleave","paste","reset","addedfile","previewElement","trim","querySelectorAll","node","name","_iteratorNormalCompletion1","_didIteratorError1","_iteratorError1","_step1","_iterator1","innerHTML","filesize","_removeLink","removeFileEvent","preventDefault","stopPropagation","status","UPLOADING","confirm","_this","_this1","removeFile","_this2","_iteratorNormalCompletion2","_didIteratorError2","_iteratorError2","_step2","_iterator2","addEventListener","removedfile","parentNode","removeChild","_updateMaxFilesReachedClass","thumbnail","dataUrl","thumbnailElement","alt","src","setTimeout","error","message","errormultiple","processing","processingmultiple","uploadprogress","progress","bytesSent","nodeName","style","totaluploadprogress","sending","sendingmultiple","success","successmultiple","canceled","emit","canceledmultiple","complete","completemultiple","maxfilesexceeded","maxfilesreached","queuecomplete","addedfiles","Emitter","el","left","clickableElements","listeners","querySelector","nodeType","dropzone","instances","elementOptions","optionsForElement","replace","isBrowserSupported","$d605d54dd3f172a3$export$2e2bcd8739ae039","getAttribute","toUpperCase","getExistingFallback","getElement","getElements","filter","accepted","map","getFilesWithStatus","QUEUED","ADDED","tagName","setAttribute","contains","setupHiddenFileInput","hiddenFileInput","visibility","position","top","_this11","addFile","URL","webkitURL","events","on","_this12","updateTotalUploadProgress","_this3","getAddedFiles","getUploadingFiles","getQueuedFiles","noPropagation","dataTransfer","types","containsFiles","returnValue","_this4","_this5","efct","effectAllowed","dropEffect","_this6","_this7","_this8","_this9","forEach","clickableElement","_this10","click","elementInside","enable","disable","removeAllFiles","indexOf","totalUploadProgress","totalBytesSent","totalBytes","getActiveFiles","total","n","existingFallback","form","fieldsString","_getParamName","fields","getFallback","elements","elementListeners","listener","removeEventListener","removeEventListeners","disabled","cancelUpload","setupEventListeners","selectedSize","selectedUnit","units","unit","pow","round","getAcceptedFiles","items","webkitGetAsEntry","_addFilesFromItems","handleFiles","clipboardData","transform","x","entry","item","isFile","getAsFile","isDirectory","_addFilesFromDirectory","kind","directory","path","dirReader","createReader","errorHandler","console","methodName","log","readEntries","entries","substring","fullPath","isValidFile","uuidv4","filename","_renameFile","_enqueueThumbnail","_errorProcessing","enqueueFile","processQueue","_thumbnailQueue","_processThumbnailQueue","_processingThumbnail","createThumbnail","$0b112e5f3be94b9d$var$without","cancelIfNecessary","canvas","resizedDataURL","toDataURL","$0b112e5f3be94b9d$var$ExifRestore","restore","dataURL","dataURItoBlob","fixOrientation","fileReader","FileReader","onload","createThumbnailFromUrl","readAsDataURL","mockFile","imageUrl","crossOrigin","param","resizeThumbnail","img","getComputedStyle","body","loadExif","EXIF","getData","getTag","orientation","resizeInfo","ctx","getContext","translate","scale","rotate","PI","$0b112e5f3be94b9d$var$drawImageIOSFix","trgX","trgY","onerror","processingLength","queuedFiles","processFiles","processFile","uploadFiles","groupedFiles","_getFilesWithXhr","groupedFile","CANCELED","abort","option","_transformFiles","transformedFiles","transformedFile","chunked","ceil","chunks","handleNextChunk","chunkIndex","startedChunkCount","start","end","dataBlock","data","webkitSlice","retries","_uploadData","finishedChunkUpload","response","allFinished","SUCCESS","responseText","responseHeaders","getAllResponseHeaders","_finished","dataBlocks","XMLHttpRequest","resolveOption","open","_finishedUploading","ontimeout","_handleUploadError","onprogress","_updateFilesUploadProgress","Accept","headerName","headerValue","setRequestHeader","submitRequest","formData","FormData","additionalParams","_getChunk","append","_addFormElementData","doneCounter","_loop","input","inputName","inputType","toLowerCase","hasAttribute","selected","checked","loaded","readyState","responseType","getResponseHeader","JSON","parse","warn","send","ERROR","c","r","random","initClass","$0b112e5f3be94b9d$var$camelize","forElement","discover","dropzones","checkElements","blockedBrowsers","capableBrowser","File","FileList","Blob","blacklistedBrowsers","navigator","userAgent","dataURI","byteString","atob","split","mimeString","ab","ArrayBuffer","ia","Uint8Array","asc","charCodeAt","list","rejectedItem","str","charAt","string","div","childNodes","container","els","question","rejected","mimeType","baseMimeType","validType","jQuery","each","ACCEPTED","PROCESSING","sx","sy","sw","sh","dx","dy","dw","dh","vertSquashRatio","naturalWidth","ih","naturalHeight","drawImage","getImageData","ey","py","ratio","$0b112e5f3be94b9d$var$detectVerticalSquash","KEY_STR","output","chr1","chr2","chr3","enc1","enc2","enc3","enc4","isNaN","origFileBase64","resizedFileBase64","rawImage","decode64","segments","slice2Segments","image","exifManipulation","encode64","exifArray","getExifArray","newImageArray","insertExif","seg","imageData","buf","separatePoint","mae","ato","array","rawImageArray","head","endPoint","exec","Dropzone"],"version":3,"file":"dropzone-min.js.map"}
\ No newline at end of file
diff --git a/public/js/dropzone.min.js b/public/js/dropzone.min.js
deleted file mode 100644
index 0453f094..00000000
--- a/public/js/dropzone.min.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(){function a(b,c,d){var e=a.resolve(b);if(null==e){d=d||b,c=c||"root";var f=new Error('Failed to require "'+d+'" from "'+c+'"');throw f.path=d,f.parent=c,f.require=!0,f}var g=a.modules[e];if(!g._resolving&&!g.exports){var h={};h.exports={},h.client=h.component=!0,g._resolving=!0,g.call(this,h.exports,a.relative(e),h),delete g._resolving,g.exports=h.exports}return g.exports}a.modules={},a.aliases={},a.resolve=function(b){"/"===b.charAt(0)&&(b=b.slice(1));for(var c=[b,b+".js",b+".json",b+"/index.js",b+"/index.json"],d=0;dd;++d)c[d].apply(this,b)}return this},d.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},d.prototype.hasListeners=function(a){return!!this.listeners(a).length}}),a.register("dropzone/index.js",function(a,b,c){c.exports=b("./lib/dropzone.js")}),a.register("dropzone/lib/dropzone.js",function(a,b,c){(function(){var a,d,e,f,g,h,i,j,k={}.hasOwnProperty,l=function(a,b){function c(){this.constructor=a}for(var d in b)k.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},m=[].slice;d="undefined"!=typeof Emitter&&null!==Emitter?Emitter:b("emitter"),i=function(){},a=function(a){function b(a,d){var e,f,g;if(this.element=a,this.version=b.version,this.defaultOptions.previewTemplate=this.defaultOptions.previewTemplate.replace(/\n*/g,""),this.clickableElements=[],this.listeners=[],this.files=[],"string"==typeof this.element&&(this.element=document.querySelector(this.element)),!this.element||null==this.element.nodeType)throw new Error("Invalid dropzone element.");if(this.element.dropzone)throw new Error("Dropzone already attached.");if(b.instances.push(this),this.element.dropzone=this,e=null!=(g=b.optionsForElement(this.element))?g:{},this.options=c({},this.defaultOptions,e,null!=d?d:{}),this.options.forceFallback||!b.isBrowserSupported())return this.options.fallback.call(this);if(null==this.options.url&&(this.options.url=this.element.getAttribute("action")),!this.options.url)throw new Error("No URL provided.");if(this.options.acceptedFiles&&this.options.acceptedMimeTypes)throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");this.options.acceptedMimeTypes&&(this.options.acceptedFiles=this.options.acceptedMimeTypes,delete this.options.acceptedMimeTypes),this.options.method=this.options.method.toUpperCase(),(f=this.getExistingFallback())&&f.parentNode&&f.parentNode.removeChild(f),this.previewsContainer=this.options.previewsContainer?b.getElement(this.options.previewsContainer,"previewsContainer"):this.element,this.options.clickable&&(this.clickableElements=this.options.clickable===!0?[this.element]:b.getElements(this.options.clickable,"clickable")),this.init()}var c;return l(b,a),b.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","addedfile","removedfile","thumbnail","error","errormultiple","processing","processingmultiple","uploadprogress","totaluploadprogress","sending","sendingmultiple","success","successmultiple","canceled","canceledmultiple","complete","completemultiple","reset","maxfilesexceeded","maxfilesreached"],b.prototype.defaultOptions={url:null,method:"post",withCredentials:!1,parallelUploads:2,uploadMultiple:!1,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:10,thumbnailWidth:100,thumbnailHeight:100,maxFiles:null,params:{},clickable:!0,ignoreHiddenFiles:!0,acceptedFiles:null,acceptedMimeTypes:null,autoProcessQueue:!0,addRemoveLinks:!1,previewsContainer:null,dictDefaultMessage:"Drop files here to upload",dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",dictFallbackText:"Please use the fallback form below to upload your files like in the olden days.",dictFileTooBig:"File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",dictInvalidFileType:"You can't upload files of this type.",dictResponseError:"Server responded with {{statusCode}} code.",dictCancelUpload:"Cancel upload",dictCancelUploadConfirmation:"Are you sure you want to cancel this upload?",dictRemoveFile:"Remove file",dictRemoveFileConfirmation:null,dictMaxFilesExceeded:"You can not upload any more files.",accept:function(a,b){return b()},init:function(){return i},forceFallback:!1,fallback:function(){var a,c,d,e,f,g;for(this.element.className=""+this.element.className+" dz-browser-not-supported",g=this.element.getElementsByTagName("div"),e=0,f=g.length;f>e;e++)a=g[e],/(^| )dz-message($| )/.test(a.className)&&(c=a,a.className="dz-message");return c||(c=b.createElement('
Last updated <%= current_site.site_updated_at.ago.downcase %>
-<% end %>
-
Using <%= current_site.space_percentage_used %>% (<%= current_site.total_space_used.to_space_pretty %>) of your <%= current_site.maximum_space.to_space_pretty %>.
-
- <% unless current_site.is_education || current_site.supporter? %>Need more space? Become a Supporter!<% end %>
- To get started, click on the index.html file below to edit your home page. Once you make changes your website will begin appearing in our website gallery. You can add more files (such as images) by dragging them from your computer into the box below. Need help building web sites? Try our HTML tutorial!
-
-<% end %>
-
-<%== flash_display %>
-
-
-
-
-
-
Uploading, please wait...
-
-
-
-
-
-
Moving file, please wait...
-
-
-
-
-
-
-
-
- <% if params[:dir].nil? || params[:dir].empty? || params[:dir] == '/' %>
- Home
- <% else %>
- Home
- <% end %>
-
- <% if @dir %>
- <% dir_array = @dir.split '/' %>
- <% dir_array.each_with_index do |dir,i| %>
- <% if i+1 < dir_array.length %>
- <%= dir %>
- <% else %>
- <%= dir %>
- <% end %>
- <% end %>
- <% end %>
-
\ No newline at end of file
diff --git a/views/dashboard/index.erb b/views/dashboard/index.erb
new file mode 100644
index 00000000..15fa0428
--- /dev/null
+++ b/views/dashboard/index.erb
@@ -0,0 +1,173 @@
+
+
+
Last updated <%= current_site.site_updated_at.ago.downcase %>
+<% end %>
+
Using <%= current_site.space_percentage_used %>% (<%= current_site.total_space_used.to_space_pretty %>) of your <%= current_site.maximum_space.to_space_pretty %>.
+
+ <% unless current_site.is_education || current_site.supporter? %>Need more space? Become a Supporter!<% end %>
+ To get started, click on the index.html file below to edit your home page. Once you make changes your website will begin appearing in our website gallery. You can add more files (such as images) by dragging them from your computer into the box below. Need help building web sites? Try our HTML tutorial!
+
+<% end %>
+
+<% if flash.keys.length > 0 %>
+
+ <% flash.keys.select {|k| [:success, :error, :errors].include?(k)}.each do |key| %>
+ <%== flash[key] %>
+ <% end %>
+