var e=class{on(e,t){return this._callbacks=this._callbacks||{},this._callbacks[e]||(this._callbacks[e]=[]),this._callbacks[e].push(t),this}emit(e,...t){this._callbacks=this._callbacks||{};let n=this._callbacks[e];if(n)for(let e of n)e.apply(this,t);return this.element&&this.element.dispatchEvent(this.makeEvent(`dropzone:`+e,{args:t})),this}makeEvent(e,t){let n={bubbles:!0,cancelable:!0,detail:t};if(typeof window.CustomEvent==`function`)return new CustomEvent(e,n);var r=document.createEvent(`CustomEvent`);return r.initCustomEvent(e,n.bubbles,n.cancelable,n.detail),r}off(e,t){if(!this._callbacks||arguments.length===0)return this._callbacks={},this;let n=this._callbacks[e];if(!n)return this;if(arguments.length===1)return delete this._callbacks[e],this;for(let e=0;e<n.length;e++)if(n[e]===t){n.splice(e,1);break}return this}},t={url:null,method:`post`,withCredentials:!1,timeout:null,parallelUploads:2,uploadMultiple:!1,chunking:!1,forceChunking:!1,chunkSize:2097152,parallelChunkUploads:!1,retryChunks:!1,retryChunksLimit:3,maxFilesize:256,paramName:`file`,createImageThumbnails:!0,maxThumbnailFilesize:10,thumbnailWidth:120,thumbnailHeight:120,thumbnailMethod:`crop`,resizeWidth:null,resizeHeight:null,resizeMimeType:null,resizeQuality:.8,resizeMethod:`contain`,filesizeBase:1e3,maxFiles:null,headers:null,defaultHeaders:!0,clickable:!0,ignoreHiddenFiles:!0,acceptedFiles:null,autoProcessQueue:!0,autoQueue:!0,addRemoveLinks:!1,previewsContainer:null,disablePreviews:!1,hiddenInputContainer:`body`,capture:null,renameFilename:null,renameFile:null,forceFallback:!1,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`,dictUploadCanceled:`Upload canceled.`,dictCancelUploadConfirmation:`Are you sure you want to cancel this upload?`,dictRemoveFile:`Remove file`,dictRemoveFileConfirmation:null,dictMaxFilesExceeded:`You cannot upload any more files.`,dictFileSizeUnits:{tb:`TB`,gb:`GB`,mb:`MB`,kb:`KB`,b:`b`},init(){},params(e,t,n){if(n)return{dzuuid:n.file.upload.uuid,dzchunkindex:n.index,dztotalfilesize:n.file.size,dzchunksize:this.options.chunkSize,dztotalchunkcount:n.file.upload.totalChunkCount,dzchunkbyteoffset:n.index*this.options.chunkSize}},accept(e,t){return t()},chunksUploaded:function(e,t){t()},binaryBody:!1,fallback(){let e;this.element.className=`${this.element.className} dz-browser-not-supported`;for(let t of this.element.getElementsByTagName(`div`))if(/(^| )dz-message($| )/.test(t.className)){e=t,t.className=`dz-message`;break}e||(e=n.createElement(`<div class="dz-message"><span></span></div>`),this.element.appendChild(e));let t=e.getElementsByTagName(`span`)[0];return t&&(t.textContent==null?t.innerText!=null&&(t.innerText=this.options.dictFallbackMessage):t.textContent=this.options.dictFallbackMessage),this.element.appendChild(this.getFallbackForm())},resize(e,t,n,r){let i={srcX:0,srcY:0,srcWidth:e.width,srcHeight:e.height},a=e.width/e.height;t==null&&n==null?(t=i.srcWidth,n=i.srcHeight):t==null?t=n*a:n??(n=t/a),t=Math.min(t,i.srcWidth),n=Math.min(n,i.srcHeight);let o=t/n;if(i.srcWidth>t||i.srcHeight>n)if(r===`crop`)a>o?(i.srcHeight=e.height,i.srcWidth=i.srcHeight*o):(i.srcWidth=e.width,i.srcHeight=i.srcWidth/o);else if(r===`contain`)a>o?n=t/a:t=n*a;else throw Error(`Unknown resizeMethod '${r}'`);return i.srcX=(e.width-i.srcWidth)/2,i.srcY=(e.height-i.srcHeight)/2,i.trgWidth=t,i.trgHeight=n,i},transformFile(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:`
<div class="dz-preview dz-file-preview">
  <div class="dz-image"><img data-dz-thumbnail /></div>
  <div class="dz-details">
    <div class="dz-size"><span data-dz-size></span></div>
    <div class="dz-filename"><span data-dz-name></span></div>
  </div>
  <div class="dz-progress">
    <span class="dz-upload" data-dz-uploadprogress></span>
  </div>
  <div class="dz-error-message"><span data-dz-errormessage></span></div>
  <div class="dz-success-mark">
    <svg
      width="54"
      height="54"
      viewBox="0 0 54 54"
      fill="white"
      xmlns="http://www.w3.org/2000/svg"
    >
      <path
        d="M10.2071 29.7929L14.2929 25.7071C14.6834 25.3166 15.3166 25.3166 15.7071 25.7071L21.2929 31.2929C21.6834 31.6834 22.3166 31.6834 22.7071 31.2929L38.2929 15.7071C38.6834 15.3166 39.3166 15.3166 39.7071 15.7071L43.7929 19.7929C44.1834 20.1834 44.1834 20.8166 43.7929 21.2071L22.7071 42.2929C22.3166 42.6834 21.6834 42.6834 21.2929 42.2929L10.2071 31.2071C9.81658 30.8166 9.81658 30.1834 10.2071 29.7929Z"
      />
    </svg>
  </div>
  <div class="dz-error-mark">
    <svg
      width="54"
      height="54"
      viewBox="0 0 54 54"
      fill="white"
      xmlns="http://www.w3.org/2000/svg"
    >
      <path
        d="M26.2929 20.2929L19.2071 13.2071C18.8166 12.8166 18.1834 12.8166 17.7929 13.2071L13.2071 17.7929C12.8166 18.1834 12.8166 18.8166 13.2071 19.2071L20.2929 26.2929C20.6834 26.6834 20.6834 27.3166 20.2929 27.7071L13.2071 34.7929C12.8166 35.1834 12.8166 35.8166 13.2071 36.2071L17.7929 40.7929C18.1834 41.1834 18.8166 41.1834 19.2071 40.7929L26.2929 33.7071C26.6834 33.3166 27.3166 33.3166 27.7071 33.7071L34.7929 40.7929C35.1834 41.1834 35.8166 41.1834 36.2071 40.7929L40.7929 36.2071C41.1834 35.8166 41.1834 35.1834 40.7929 34.7929L33.7071 27.7071C33.3166 27.3166 33.3166 26.6834 33.7071 26.2929L40.7929 19.2071C41.1834 18.8166 41.1834 18.1834 40.7929 17.7929L36.2071 13.2071C35.8166 12.8166 35.1834 12.8166 34.7929 13.2071L27.7071 20.2929C27.3166 20.6834 26.6834 20.6834 26.2929 20.2929Z"
      />
    </svg>
  </div>
</div>`,drop(e){return this.element.classList.remove(`dz-drag-hover`)},dragstart(e){},dragend(e){return this.element.classList.remove(`dz-drag-hover`)},dragenter(e){return this.element.classList.add(`dz-drag-hover`)},dragover(e){return this.element.classList.add(`dz-drag-hover`)},dragleave(e){return this.element.classList.remove(`dz-drag-hover`)},paste(e){},reset(){return this.element.classList.remove(`dz-started`)},addedfile(e){if(this.element===this.previewsContainer&&this.element.classList.add(`dz-started`),this.previewsContainer&&!this.options.disablePreviews){e.previewElement=n.createElement(this.options.previewTemplate.trim()),e.previewTemplate=e.previewElement,this.previewsContainer.appendChild(e.previewElement);for(var t of e.previewElement.querySelectorAll(`[data-dz-name]`))t.textContent=e.name;for(t of e.previewElement.querySelectorAll(`[data-dz-size]`))t.innerHTML=this.filesize(e.size);this.options.addRemoveLinks&&(e._removeLink=n.createElement(`<a class="dz-remove" href="javascript:undefined;" data-dz-remove>${this.options.dictRemoveFile}</a>`),e.previewElement.appendChild(e._removeLink));let r=t=>(t.preventDefault(),t.stopPropagation(),e.status===n.UPLOADING?this.options.dictCancelUploadConfirmation?n.confirm(this.options.dictCancelUploadConfirmation,()=>this.removeFile(e)):this.removeFile(e):this.options.dictRemoveFileConfirmation?n.confirm(this.options.dictRemoveFileConfirmation,()=>this.removeFile(e)):this.removeFile(e));for(let t of e.previewElement.querySelectorAll(`[data-dz-remove]`))t.addEventListener(`click`,r)}},removedfile(e){return e.previewElement!=null&&e.previewElement.parentNode!=null&&e.previewElement.parentNode.removeChild(e.previewElement),this._updateMaxFilesReachedClass()},thumbnail(e,t){if(e.previewElement){e.previewElement.classList.remove(`dz-file-preview`);for(let n of e.previewElement.querySelectorAll(`[data-dz-thumbnail]`))n.alt=e.name,n.src=t;return setTimeout(()=>e.previewElement.classList.add(`dz-image-preview`),1)}},error(e,t){if(e.previewElement){e.previewElement.classList.add(`dz-error`),typeof t!=`string`&&t.error&&(t=t.error);for(let n of e.previewElement.querySelectorAll(`[data-dz-errormessage]`))n.textContent=t}},errormultiple(){},processing(e){if(e.previewElement&&(e.previewElement.classList.add(`dz-processing`),e._removeLink))return e._removeLink.innerHTML=this.options.dictCancelUpload},processingmultiple(){},uploadprogress(e,t,n){if(e.previewElement)for(let n of e.previewElement.querySelectorAll(`[data-dz-uploadprogress]`))n.nodeName===`PROGRESS`?n.value=t:n.style.width=`${t}%`},totaluploadprogress(){},sending(){},sendingmultiple(){},success(e){if(e.previewElement)return e.previewElement.classList.add(`dz-success`)},successmultiple(){},canceled(e){return this.emit(`error`,e,this.options.dictUploadCanceled)},canceledmultiple(){},complete(e){if(e._removeLink&&(e._removeLink.innerHTML=this.options.dictRemoveFile),e.previewElement)return e.previewElement.classList.add(`dz-complete`)},completemultiple(){},maxfilesexceeded(){},maxfilesreached(){},queuecomplete(){},addedfiles(){},emptyfolder(){}},n=class n extends e{static initClass(){this.prototype.Emitter=e,this.prototype.events=`drop.dragstart.dragend.dragenter.dragover.dragleave.addedfile.addedfiles.removedfile.thumbnail.error.errormultiple.processing.processingmultiple.uploadprogress.totaluploadprogress.sending.sendingmultiple.success.successmultiple.canceled.canceledmultiple.complete.completemultiple.reset.maxfilesexceeded.maxfilesreached.queuecomplete.emptyfolder`.split(`.`),this.prototype._thumbnailQueue=[],this.prototype._processingThumbnail=!1}constructor(e,r){super();let i;if(this.element=e,this.clickableElements=[],this.listeners=[],this.files=[],typeof this.element==`string`&&(this.element=document.querySelector(this.element)),this.element===null||!this.element instanceof HTMLElement)throw Error(`Invalid dropzone element: not an instance of HTMLElement.`);if(this.element.dropzone)throw Error(`Dropzone already attached.`);n.instances.push(this),this.element.dropzone=this;let a=n.optionsForElement(this.element)??{};if(this.options=Object.assign({},t,a,r??{}),this.options.previewTemplate=this.options.previewTemplate.replace(/\n*/g,``),this.options.forceFallback||!n.isBrowserSupported())return this.options.fallback.call(this);if(this.options.url??(this.options.url=this.element.getAttribute(`action`)),!this.options.url)throw Error(`No URL provided.`);if(this.options.uploadMultiple&&this.options.chunking)throw Error(`You cannot set both: uploadMultiple and chunking.`);if(this.options.binaryBody&&this.options.uploadMultiple)throw Error(`You cannot set both: binaryBody and uploadMultiple.`);typeof this.options.method==`string`&&(this.options.method=this.options.method.toUpperCase()),(i=this.getExistingFallback())&&i.parentNode&&i.parentNode.removeChild(i),this.options.previewsContainer!==!1&&(this.options.previewsContainer?this.previewsContainer=n.getElement(this.options.previewsContainer,`previewsContainer`):this.previewsContainer=this.element),this.options.clickable&&(this.options.clickable===!0?this.clickableElements=[this.element]:this.clickableElements=n.getElements(this.options.clickable,`clickable`)),this.init()}getAcceptedFiles(){return this.files.filter(e=>e.accepted).map(e=>e)}getRejectedFiles(){return this.files.filter(e=>!e.accepted).map(e=>e)}getFilesWithStatus(e){return this.files.filter(t=>t.status===e).map(e=>e)}getQueuedFiles(){return this.getFilesWithStatus(n.QUEUED)}getUploadingFiles(){return this.getFilesWithStatus(n.UPLOADING)}getAddedFiles(){return this.getFilesWithStatus(n.ADDED)}getActiveFiles(){return this.files.filter(e=>e.status===n.UPLOADING||e.status===n.QUEUED).map(e=>e)}init(){if(this.element.tagName===`form`&&this.element.setAttribute(`enctype`,`multipart/form-data`),this.element.classList.contains(`dropzone`)&&!this.element.querySelector(`.dz-message`)&&this.element.appendChild(n.createElement(`<div class="dz-default dz-message"><button class="dz-button" type="button">${this.options.dictDefaultMessage}</button></div>`)),this.clickableElements.length){let e=()=>{this.hiddenFileInput&&this.hiddenFileInput.parentNode?.removeChild(this.hiddenFileInput),this.hiddenFileInput=document.createElement(`input`),this.hiddenFileInput.setAttribute(`type`,`file`),this.hiddenFileInput.setAttribute(`form`,this.element.id),(this.options.maxFiles===null||this.options.maxFiles>1)&&this.hiddenFileInput.setAttribute(`multiple`,`multiple`),this.hiddenFileInput.className=`dz-hidden-input`,this.options.acceptedFiles!==null&&this.hiddenFileInput.setAttribute(`accept`,this.options.acceptedFiles),this.options.capture!==null&&this.hiddenFileInput.setAttribute(`capture`,this.options.capture),this.hiddenFileInput.setAttribute(`tabindex`,`-1`),this.hiddenFileInput.setAttribute(`aria-label`,`dropzone hidden input`),this.hiddenFileInput.style.visibility=`hidden`,this.hiddenFileInput.style.position=`absolute`,this.hiddenFileInput.style.top=`0`,this.hiddenFileInput.style.left=`0`,this.hiddenFileInput.style.height=`0`,this.hiddenFileInput.style.width=`0`,n.getElement(this.options.hiddenInputContainer,`hiddenInputContainer`).appendChild(this.hiddenFileInput),this.hiddenFileInput.addEventListener(`change`,()=>{let{files:t}=this.hiddenFileInput;if(t.length)for(let e of t)this.addFile(e);this.emit(`addedfiles`,t),e()})};e()}this.URL=window.URL===null?window.webkitURL:window.URL;for(let e of this.events)this.on(e,this.options[e]);this.on(`uploadprogress`,()=>this.updateTotalUploadProgress()),this.on(`removedfile`,()=>this.updateTotalUploadProgress()),this.on(`canceled`,e=>this.emit(`complete`,e)),this.on(`complete`,e=>{if(this.getAddedFiles().length===0&&this.getUploadingFiles().length===0&&this.getQueuedFiles().length===0)return setTimeout(()=>this.emit(`queuecomplete`),0)});let e=function(e){return e.dataTransfer.types&&e.dataTransfer.types.includes(`Files`)},t=function(t){if(e(t))return t.stopPropagation(),t.preventDefault()};return this.listeners=[{element:this.element,events:{dragstart:e=>this.emit(`dragstart`,e),dragenter:e=>(t(e),this.emit(`dragenter`,e)),dragover:e=>{let n=e.dataTransfer.effectAllowed;return e.dataTransfer.dropEffect=n===`move`||n===`linkMove`?`move`:`copy`,t(e),this.emit(`dragover`,e)},dragleave:e=>this.emit(`dragleave`,e),drop:e=>(t(e),this.drop(e)),dragend:e=>this.emit(`dragend`,e)}}],this.clickableElements.forEach(e=>this.listeners.push({element:e,events:{click:t=>((e!==this.element||t.target===this.element||n.elementInside(t.target,this.element.querySelector(`.dz-message`)))&&this.hiddenFileInput.click(),!0)}})),this.enable(),this.options.init.call(this)}destroy(){return this.disable(),this.removeAllFiles(!0),this.hiddenFileInput!=null&&this.hiddenFileInput.parentNode&&(this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput),this.hiddenFileInput=null),delete this.element.dropzone,n.instances.splice(n.instances.indexOf(this),1)}updateTotalUploadProgress(){let e,t=0,n=0;if(this.getActiveFiles().length){for(let e of this.getActiveFiles())t+=e.upload.bytesSent,n+=e.upload.total;e=100*t/n}else e=100;return this.emit(`totaluploadprogress`,e,n,t)}_getParamName(e){return typeof this.options.paramName==`function`?this.options.paramName(e):`${this.options.paramName}${this.options.uploadMultiple?`[${e}]`:``}`}_renameFile(e){let t={...e,name:e.name.replace(/\u202F/g,` `)};return typeof this.options.renameFile==`function`?this.options.renameFile(t):t.name}getFallbackForm(){let e,t;if(e=this.getExistingFallback())return e;let r=`<div class="dz-fallback">`;this.options.dictFallbackText&&(r+=`<p>${this.options.dictFallbackText}</p>`),r+=`<input type="file" name="${this._getParamName(0)}" ${this.options.uploadMultiple?`multiple="multiple"`:void 0} /><input type="submit" value="Upload!"></div>`;let i=n.createElement(r);return this.element.tagName===`FORM`?(this.element.setAttribute(`enctype`,`multipart/form-data`),this.element.setAttribute(`method`,this.options.method)):(t=n.createElement(`<form action="${this.options.url}" enctype="multipart/form-data" method="${this.options.method}"></form>`),t.appendChild(i)),t??i}getExistingFallback(){let e=function(e){for(let t of e)if(/(^| )fallback($| )/.test(t.className))return t};for(let n of[`div`,`form`]){var t;if(t=e(this.element.getElementsByTagName(n)))return t}}setupEventListeners(){return this.listeners.map(e=>(()=>{let t=[];for(let n in e.events){let r=e.events[n];t.push(e.element.addEventListener(n,r,!1))}return t})())}removeEventListeners(){return this.listeners.map(e=>(()=>{let t=[];for(let n in e.events){let r=e.events[n];t.push(e.element.removeEventListener(n,r,!1))}return t})())}disable(){return this.clickableElements.forEach(e=>e.classList.remove(`dz-clickable`)),this.removeEventListeners(),this.disabled=!0,this.files.map(e=>this.cancelUpload(e))}enable(){return delete this.disabled,this.clickableElements.forEach(e=>e.classList.add(`dz-clickable`)),this.setupEventListeners()}filesize(e){let t=0,n=`b`;if(e>0){let r=[`tb`,`gb`,`mb`,`kb`,`b`];for(let i=0;i<r.length;i++){let a=r[i];if(e>=this.options.filesizeBase**(4-i)/10){t=e/this.options.filesizeBase**(4-i),n=a;break}}t=Math.round(10*t)/10}return`<strong>${t}</strong> ${this.options.dictFileSizeUnits[n]}`}_updateMaxFilesReachedClass(){return this.options.maxFiles!=null&&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`)}drop(e){if(!e.dataTransfer)return;this.emit(`drop`,e);let t=[];for(let n=0;n<e.dataTransfer.files.length;n++)t[n]=e.dataTransfer.files[n];if(t.length){let{items:n}=e.dataTransfer;n&&n.length&&n[0].webkitGetAsEntry!=null?this._addFilesFromItems(n):this.handleFiles(t)}this.emit(`addedfiles`,t)}paste(e){if(l(e?.clipboardData,e=>e.items)==null)return;this.emit(`paste`,e);let{items:t}=e.clipboardData;if(t.length)return this._addFilesFromItems(t)}handleFiles(e){for(let t of e)this.addFile(t)}_addFilesFromItems(e){return(()=>{let t=[];for(let r of e){var n;r.webkitGetAsEntry!=null&&(n=r.webkitGetAsEntry())?n.isFile?t.push(this.addFile(r.getAsFile())):n.isDirectory?t.push(this._addFilesFromDirectory(n,n.name)):t.push(void 0):r.getAsFile==null?t.push(void 0):r.kind==null||r.kind===`file`?t.push(this.addFile(r.getAsFile())):t.push(void 0)}return t})()}_addFilesFromDirectory(e,t){let n=e.createReader(),r=e=>u(console,`log`,t=>t.log(e)),i=0;var a=()=>n.readEntries(e=>{if(e.length>0){for(let n of e)n.isFile?(++i,n.file(e=>{if(!(this.options.ignoreHiddenFiles&&e.name.substring(0,1)===`.`))return e.fullPath=`${t}/${e.name}`,this.addFile(e)})):n.isDirectory&&this._addFilesFromDirectory(n,`${t}/${n.name}`);a()}else i===0&&this.emit(`emptyfolder`,t);return null},r);return a()}accept(e,t){this.options.maxFilesize&&e.size>this.options.maxFilesize*1048576?t(this.options.dictFileTooBig.replace(`{{filesize}}`,Math.round(e.size/1024/10.24)/100).replace(`{{maxFilesize}}`,this.options.maxFilesize)):n.isValidFile(e,this.options.acceptedFiles)?this.options.maxFiles!=null&&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)}addFile(e){e.upload={uuid:window.isSecureContext?self.crypto.randomUUID():n.uuidv4(),progress:0,total:e.size,bytesSent:0,filename:this._renameFile(e)},this.files.push(e),e.status=n.ADDED,this.emit(`addedfile`,e),this._enqueueThumbnail(e),this.accept(e,t=>{t?(e.accepted=!1,this._errorProcessing([e],t)):(e.accepted=!0,this.options.autoQueue&&this.enqueueFile(e)),this._updateMaxFilesReachedClass()})}enqueueFiles(e){for(let t of e)this.enqueueFile(t);return null}enqueueFile(e){if(e.status===n.ADDED&&e.accepted===!0){if(e.status=n.QUEUED,this.options.autoProcessQueue)return setTimeout(()=>this.processQueue(),0)}else throw Error(`This file can't be queued because it has already been processed or was rejected.`)}_enqueueThumbnail(e){if(this.options.createImageThumbnails&&e.type.match(/image.*/)&&e.size<=this.options.maxThumbnailFilesize*1048576)return this._thumbnailQueue.push(e),setTimeout(()=>this._processThumbnailQueue(),0)}_processThumbnailQueue(){if(this._processingThumbnail||this._thumbnailQueue.length===0)return;this._processingThumbnail=!0;let e=this._thumbnailQueue.shift();return this.createThumbnail(e,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,!0,t=>(this.emit(`thumbnail`,e,t),this._processingThumbnail=!1,this._processThumbnailQueue()))}removeFile(e){if(e.status===n.UPLOADING&&this.cancelUpload(e),this.files=r(this.files,e),this.emit(`removedfile`,e),this.files.length===0)return this.emit(`reset`)}removeAllFiles(e){e??(e=!1);for(let t of this.files.slice())(t.status!==n.UPLOADING||e)&&this.removeFile(t);return null}resizeImage(e,t,r,i,a){return this.createThumbnail(e,t,r,i,!0,(t,r)=>{if(r==null)return a(e);{let{resizeMimeType:t}=this.options;t??(t=e.type);let i=r.toDataURL(t,this.options.resizeQuality);return(t===`image/jpeg`||t===`image/jpg`)&&(i=c(e.dataURL,i)),a(n.dataURItoBlob(i))}},!0)}createThumbnail(e,t,n,r,i,a,o=!1){let s=new FileReader;s.onload=()=>{if(e.dataURL=s.result,e.type===`image/svg+xml`||e.type===`image/gif`){a?.(s.result);return}this.createThumbnailFromUrl(e,t,n,r,i,a,void 0,o)},s.readAsDataURL(e)}displayExistingFile(e,t,n,r,i=!0){this.emit(`addedfile`,e),this.emit(`complete`,e),i?(e.dataURL=t,this.createThumbnailFromUrl(e,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,this.options.fixOrientation,t=>{this.emit(`thumbnail`,e,t),n&&n()},r)):(this.emit(`thumbnail`,e,t),n&&n())}createThumbnailFromUrl(e,t,n,r,i,a,c,l=!1){let u=document.createElement(`img`);c&&(u.crossOrigin=c),i=getComputedStyle(document.body).imageOrientation==`from-image`?!1:i,u.onload=()=>{let s=e=>e(1);return typeof EXIF<`u`&&EXIF!==null&&i&&(s=e=>EXIF.getData(u,function(){return e(EXIF.getTag(this,`Orientation`))})),s(i=>{e.width=u.width,e.height=u.height;let s=this.options.resize.call(this,e,t,n,r),c=document.createElement(`canvas`),l=c.getContext(`2d`);switch(c.width=s.trgWidth,c.height=s.trgHeight,i>4&&(c.width=s.trgHeight,c.height=s.trgWidth),i){case 2:l.translate(c.width,0),l.scale(-1,1);break;case 3:l.translate(c.width,c.height),l.rotate(Math.PI);break;case 4:l.translate(0,c.height),l.scale(1,-1);break;case 5:l.rotate(.5*Math.PI),l.scale(1,-1);break;case 6:l.rotate(.5*Math.PI),l.translate(0,-c.width);break;case 7:l.rotate(.5*Math.PI),l.translate(c.height,-c.width),l.scale(-1,1);break;case 8:l.rotate(-.5*Math.PI),l.translate(-c.height,0);break}o(l,u,s.srcX==null?0:s.srcX,s.srcY==null?0:s.srcY,s.srcWidth,s.srcHeight,s.trgX==null?0:s.trgX,s.trgY==null?0:s.trgY,s.trgWidth,s.trgHeight);let d=c.toDataURL(`image/png`);if(a!=null)return a(d,c)})},a!=null&&(u.onerror=a);var d=e.dataURL;return l&&(d=s(d)),u.src=d}processQueue(){let{parallelUploads:e}=this.options,t=this.getUploadingFiles().length,n=t;if(t>=e)return;let r=this.getQueuedFiles();if(r.length>0){if(this.options.uploadMultiple)return this.processFiles(r.slice(0,e-t));for(;n<e;){if(!r.length)return;this.processFile(r.shift()),n++}}}processFile(e){return this.processFiles([e])}processFiles(e){for(let t of e)t.processing=!0,t.status=n.UPLOADING,this.emit(`processing`,t);return this.options.uploadMultiple&&this.emit(`processingmultiple`,e),this.uploadFiles(e)}_getFilesWithXhr(e){return this.files.filter(t=>t.xhr===e).map(e=>e)}cancelUpload(e){if(e.status===n.UPLOADING){let t=this._getFilesWithXhr(e.xhr);for(let e of t)e.status=n.CANCELED;e.xhr!==void 0&&e.xhr.abort();for(let e of t)this.emit(`canceled`,e);this.options.uploadMultiple&&this.emit(`canceledmultiple`,t)}else(e.status===n.ADDED||e.status===n.QUEUED)&&(e.status=n.CANCELED,this.emit(`canceled`,e),this.options.uploadMultiple&&this.emit(`canceledmultiple`,[e]));if(this.options.autoProcessQueue)return this.processQueue()}resolveOption(e,...t){return typeof e==`function`?e.apply(this,t):e}uploadFile(e){return this.uploadFiles([e])}uploadFiles(e){this._transformFiles(e,t=>{if(this.options.chunking){let n=t[0];e[0].upload.chunked=this.options.chunking&&(this.options.forceChunking||n.size>this.options.chunkSize),e[0].upload.totalChunkCount=Math.ceil(n.size/this.options.chunkSize),n.size===0&&(e[0].upload.totalChunkCount=1)}if(e[0].upload.chunked){let r=e[0],i=t[0];r.upload.chunks=[];let a=()=>{let t=0;for(;r.upload.chunks[t]!==void 0;)t++;if(t>=r.upload.totalChunkCount)return;let a=t*this.options.chunkSize,o=Math.min(a+this.options.chunkSize,i.size),s={name:this._getParamName(0),data:i.webkitSlice?i.webkitSlice(a,o):i.slice(a,o),filename:r.upload.filename,chunkIndex:t};r.upload.chunks[t]={file:r,index:t,dataBlock:s,status:n.UPLOADING,progress:0,retries:0},this._uploadData(e,[s])};if(r.upload.finishedChunkUpload=(t,i)=>{let o=!0;t.status=n.SUCCESS,t.dataBlock=null,t.response=t.xhr.responseText,t.responseHeaders=t.xhr.getAllResponseHeaders(),t.xhr=null;for(let e=0;e<r.upload.totalChunkCount;e++){if(r.upload.chunks[e]===void 0)return a();r.upload.chunks[e].status!==n.SUCCESS&&(o=!1)}o&&this.options.chunksUploaded(r,()=>{this._finished(e,i,null)})},this.options.parallelChunkUploads){let e=Math.min(this.options.parallelChunkUploads===!0?this.options.parallelUploads:this.options.parallelChunkUploads,r.upload.totalChunkCount);for(let t=0;t<e;t++)a()}else a()}else{let n=[];for(let r=0;r<e.length;r++)n[r]={name:this._getParamName(r),data:t[r],filename:e[r].upload.filename};this._uploadData(e,n)}})}_getChunk(e,t){for(let n=0;n<e.upload.totalChunkCount;n++)if(e.upload.chunks[n]!==void 0&&e.upload.chunks[n].xhr===t)return e.upload.chunks[n]}_uploadData(e,t){let n=new XMLHttpRequest;for(let t of e)t.xhr=n;e[0].upload.chunked&&(e[0].upload.chunks[t[0].chunkIndex].xhr=n);let r=this.resolveOption(this.options.method,e,t),i=this.resolveOption(this.options.url,e,t);n.open(r,i,!0),this.resolveOption(this.options.timeout,e)&&(n.timeout=this.resolveOption(this.options.timeout,e)),n.withCredentials=!!this.options.withCredentials,n.onload=t=>{this._finishedUploading(e,n,t)},n.ontimeout=()=>{this._handleUploadError(e,n,`Request timedout after ${this.options.timeout/1e3} seconds`)},n.onerror=()=>{this._handleUploadError(e,n)};let a=n.upload==null?n:n.upload;a.onprogress=t=>this._updateFilesUploadProgress(e,n,t);let o=this.options.defaultHeaders?{Accept:`application/json`,"Cache-Control":`no-cache`,"X-Requested-With":`XMLHttpRequest`}:{};this.options.binaryBody&&(o[`Content-Type`]=e[0].type),this.options.headers&&Object.assign(o,this.options.headers);for(let e in o){let t=o[e];t&&n.setRequestHeader(e,t)}if(this.options.binaryBody){for(let t of e)this.emit(`sending`,t,n);this.options.uploadMultiple&&this.emit(`sendingmultiple`,e,n),this.submitRequest(n,null,e)}else{let r=new FormData;if(this.options.params){let t=this.options.params;typeof t==`function`&&(t=t.call(this,e,n,e[0].upload.chunked?this._getChunk(e[0],n):null));for(let e in t){let n=t[e];if(Array.isArray(n))for(let t=0;t<n.length;t++)r.append(e,n[t]);else r.append(e,n)}}for(let t of e)this.emit(`sending`,t,n,r);this.options.uploadMultiple&&this.emit(`sendingmultiple`,e,n,r),this._addFormElementData(r);for(let e=0;e<t.length;e++){let n=t[e];r.append(n.name,n.data,n.filename)}this.submitRequest(n,r,e)}}_transformFiles(e,t){let n=[],r=0;for(let i=0;i<e.length;i++)this.options.transformFile.call(this,e[i],a=>{n[i]=a,++r===e.length&&t(n)})}_addFormElementData(e){if(this.element.tagName===`FORM`)for(let t of this.element.querySelectorAll(`input, textarea, select, button`)){let n=t.getAttribute(`name`),r=t.getAttribute(`type`);if(r&&(r=r.toLowerCase()),n!=null)if(t.tagName===`SELECT`&&t.hasAttribute(`multiple`))for(let r of t.options)r.selected&&e.append(n,r.value);else(!r||r!==`checkbox`&&r!==`radio`||t.checked)&&e.append(n,t.value)}}_updateFilesUploadProgress(e,t,n){if(e[0].upload.chunked){let r=e[0],i=this._getChunk(r,t);n?(i.progress=100*n.loaded/n.total,i.total=n.total,i.bytesSent=n.loaded):(i.progress=100,i.bytesSent=i.total),r.upload.progress=0,r.upload.total=0,r.upload.bytesSent=0;for(let e=0;e<r.upload.totalChunkCount;e++)r.upload.chunks[e]&&r.upload.chunks[e].progress!==void 0&&(r.upload.progress+=r.upload.chunks[e].progress,r.upload.total+=r.upload.chunks[e].total,r.upload.bytesSent+=r.upload.chunks[e].bytesSent);r.upload.progress=r.upload.progress/r.upload.totalChunkCount,this.emit(`uploadprogress`,r,r.upload.progress,r.upload.bytesSent)}else for(let t of e)t.upload.total&&t.upload.bytesSent&&t.upload.bytesSent==t.upload.total||(n?(t.upload.progress=100*n.loaded/n.total,t.upload.total=n.total,t.upload.bytesSent=n.loaded):(t.upload.progress=100,t.upload.bytesSent=t.upload.total),this.emit(`uploadprogress`,t,t.upload.progress,t.upload.bytesSent))}_finishedUploading(e,t,r){let i;if(e[0].status!==n.CANCELED&&t.readyState===4){if(t.responseType!==`arraybuffer`&&t.responseType!==`blob`&&(i=t.responseText,t.getResponseHeader(`content-type`)&&~t.getResponseHeader(`content-type`).indexOf(`application/json`)))try{i=JSON.parse(i)}catch(e){r=e,i=`Invalid JSON response from server.`}this._updateFilesUploadProgress(e,t),200<=t.status&&t.status<300?e[0].upload.chunked?e[0].upload.finishedChunkUpload(this._getChunk(e[0],t),i):this._finished(e,i,r):this._handleUploadError(e,t,i)}}_handleUploadError(e,t,r){if(e[0].status!==n.CANCELED){if(e[0].upload.chunked&&this.options.retryChunks){let n=this._getChunk(e[0],t);if(n.retries++<this.options.retryChunksLimit){this._uploadData(e,[n.dataBlock]);return}else console.warn(`Retried this chunk too often. Giving up.`)}this._errorProcessing(e,r||this.options.dictResponseError.replace(`{{statusCode}}`,t.status),t)}}submitRequest(e,t,n){if(e.readyState!=1){console.warn(`Cannot send this request because the XMLHttpRequest.readyState is not OPENED.`);return}if(this.options.binaryBody)if(n[0].upload.chunked){let t=this._getChunk(n[0],e);e.send(t.dataBlock.data)}else e.send(n[0]);else e.send(t)}_finished(e,t,r){for(let i of e)i.status=n.SUCCESS,this.emit(`success`,i,t,r),this.emit(`complete`,i);if(this.options.uploadMultiple&&(this.emit(`successmultiple`,e,t,r),this.emit(`completemultiple`,e)),this.options.autoProcessQueue)return this.processQueue()}_errorProcessing(e,t,r){for(let i of e)i.status=n.ERROR,this.emit(`error`,i,t,r),this.emit(`complete`,i);if(this.options.uploadMultiple&&(this.emit(`errormultiple`,e,t,r),this.emit(`completemultiple`,e)),this.options.autoProcessQueue)return this.processQueue()}static uuidv4(){return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}};n.initClass(),n.options={},n.optionsForElement=function(e){if(e.getAttribute(`id`)&&n.options!==void 0)return n.options[i(e.getAttribute(`id`))]},n.instances=[],n.forElement=function(e){if(typeof e==`string`&&(e=document.querySelector(e)),e?.dropzone==null)throw Error("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.");return e.dropzone},n.discover=function(){let e;if(document.querySelectorAll)e=document.querySelectorAll(`.dropzone`);else{e=[];let t=t=>(()=>{let n=[];for(let r of t)/(^| )dropzone($| )/.test(r.className)?n.push(e.push(r)):n.push(void 0);return n})();t(document.getElementsByTagName(`div`)),t(document.getElementsByTagName(`form`))}return(()=>{let t=[];for(let r of e)n.optionsForElement(r)===!1?t.push(void 0):t.push(new n(r));return t})()},n.isBrowserSupported=function(){return typeof Promise<`u`},n.dataURItoBlob=function(e){let t=atob(e.split(`,`)[1]),n=e.split(`,`)[0].split(`:`)[1].split(`;`)[0],r=new ArrayBuffer(t.length),i=new Uint8Array(r);for(let e=0,n=t.length,r=0<=n;r?e<=n:e>=n;r?e++:e--)i[e]=t.charCodeAt(e);return new Blob([r],{type:n})};var r=(e,t)=>e.filter(e=>e!==t).map(e=>e),i=e=>e.replace(/[\-_](\w)/g,e=>e.charAt(1).toUpperCase());n.createElement=function(e){let t=document.createElement(`div`);return t.innerHTML=e,t.childNodes[0]},n.elementInside=function(e,t){if(e===t)return!0;for(;e=e.parentNode;)if(e===t)return!0;return!1},n.getElement=function(e,t){let n;if(typeof e==`string`?n=document.querySelector(e):e.nodeType!=null&&(n=e),n==null)throw Error(`Invalid \`${t}\` option provided. Please provide a CSS selector or a plain HTML element.`);return n},n.getElements=function(e,t){let n,r;if(e instanceof Array){r=[];try{for(n of e)r.push(this.getElement(n,t))}catch{r=null}}else if(typeof e==`string`){r=[];for(n of document.querySelectorAll(e))r.push(n)}else e.nodeType!=null&&(r=[e]);if(r==null||!r.length)throw Error(`Invalid \`${t}\` option provided. Please provide a CSS selector, a plain HTML element or a list of those.`);return r},n.confirm=function(e,t,n){if(window.confirm(e))return t();if(n!=null)return n()},n.isValidFile=function(e,t){if(!t)return!0;t=t.split(`,`);let n=e.type,r=n.replace(/\/.*$/,``);for(let i of t)if(i=i.trim(),i.charAt(0)===`.`){if(e.name.toLowerCase().indexOf(i.toLowerCase(),e.name.length-i.length)!==-1)return!0}else if(/\/\*$/.test(i)){if(r===i.replace(/\/.*$/,``))return!0}else if(n===i)return!0;return!1},typeof jQuery<`u`&&jQuery!==null&&(jQuery.fn.dropzone=function(e){return this.each(function(){return new n(this,e)})}),n.ADDED=`added`,n.QUEUED=`queued`,n.ACCEPTED=n.QUEUED,n.UPLOADING=`uploading`,n.PROCESSING=n.UPLOADING,n.CANCELED=`canceled`,n.ERROR=`error`,n.SUCCESS=`success`;var a=function(e){let t=e.naturalHeight,n=document.createElement(`canvas`);n.width=1,n.height=t;let r=n.getContext(`2d`);r.drawImage(e,0,0);let{data:i}=r.getImageData(1,0,1,t),a=0,o=t,s=t;for(;s>a;)i[(s-1)*4+3]===0?o=s:a=s,s=o+a>>1;let c=s/t;return c===0?1:c},o=function(e,t,n,r,i,o,s,c,l,u){let d=a(t);return e.drawImage(t,n,r,i,o,s,c,l,u/d)};function s(e){var t=`data:image/jpeg;base64,`;if(!e.startsWith(t))return e;var n=window.atob(e.slice(t.length));if(!n.startsWith(`ÿØÿ`))return e;for(var r=0,i=``;r<n.length;)if(n.slice(r,r+2)==`ÿÚ`){i+=n.slice(r);break}else if(n.slice(r,r+2)==`ÿØ`)i+=n.slice(r,r+2),r+=2;else{var a=n.charCodeAt(r+2)*256+n.charCodeAt(r+3),o=r+a+2,s=n.slice(r,o);s.startsWith(`ÿá`)||(i+=s),r=o}return t+window.btoa(i)}function c(e,t){var n=`data:image/jpeg;base64,`;if(!(e.startsWith(n)&&t.startsWith(n)))return t;var r=window.atob(e.slice(n.length));if(!r.startsWith(`ÿØÿ`))return t;for(var i=0,a=``;i<r.length&&r.slice(i,i+2)!=`ÿÚ`;)if(r.slice(i,i+2)==`ÿØ`)i+=2;else{var o=r.charCodeAt(i+2)*256+r.charCodeAt(i+3),s=i+o+2,c=r.slice(i,s);c.startsWith(`ÿá`)&&(a+=c),i=s}if(a==``)return t;var l=window.atob(t.slice(n.length));if(!l.startsWith(`ÿØÿ`))return t;var u=4+l.charCodeAt(4)*256+l.charCodeAt(5);return l=l.slice(0,u)+a+l.slice(u),n+window.btoa(l)}function l(e,t){return e==null?void 0:t(e)}function u(e,t,n){if(e!=null&&typeof e[t]==`function`)return n(e,t)}export{n as Dropzone,n as default};
//# sourceMappingURL=dropzone.9FIWmXUy.js.map