import{p as t}from"./file-validation.util.esm.js";import{F as s}from"../types/file-upload.enums.esm.js";class e{constructor(){this.currentState=s.DEFAULT}setErrorMessage(t){this.errorMessageCallback=t}setIsDisabled(t){this.isDisabledCallback=t}setValuesInDragHandler(t){this.currentState=t}onFileDrop(t){this.fileDropCallback=t}onStateChange(t){this.stateChangeCallback=t}setState(t){this.currentState===s.DISABLED||this.isDisabledCallback?.()||(this.currentState=t,this.stateChangeCallback?.(t))}dragEnter(e){t(e),this.currentState===s.DISABLED||this.isDisabledCallback?.()||this.setState(s.DRAG)}dragLeave(e){t(e),this.currentState===s.DISABLED||this.isDisabledCallback?.()||this.setState(s.DEFAULT)}dragOver(e){t(e),this.currentState!==s.DISABLED&&this.isDisabledCallback?.()}drop(e){t(e),this.currentState===s.DISABLED||this.isDisabledCallback?.()||(this.setState(s.DEFAULT),this.handleFiles(e))}handleDocumentDrop(e){t(e),this.currentState!==s.DISABLED&&this.setState(s.DEFAULT)}preventDragOver(s){t(s)}preventDrop(s){t(s)}handleFiles(e){if(t(e),this.currentState===s.DISABLED||this.isDisabledCallback?.())return;let i=null;if("dataTransfer"in e&&e.dataTransfer&&(i=e.dataTransfer.files),!i&&e.target instanceof HTMLInputElement&&(i=e.target.files),i&&i.length>0){const t=Array.from(i);this.fileDropCallback?.(t)}e.target instanceof HTMLInputElement&&(e.target.value="")}}export{e as D};
