text: var e=require("@hotwired/stimulus");require("@kanety/stimulus-static-actions");class t extends e.Controller{get input(){return this.scope.findElement("input[type=file]")}connect(){this.counter=0}enter(e){e.preventDefault(),this.isDroppable(e.dataTransfer)&&(this.counter++,this.toggleClass(e.dataTransfer,!0))}leave(e){e.preventDefault(),this.isDroppable(e.dataTransfer)&&(this.counter--,0==this.counter&&this.toggleClass(e.dataTransfer,!1))}drop(e){if(e.preventDefault(),this.isDroppable(e.dataTransfer)){this.counter=0,this.toggleClass(e.dataTransfer,!1);var t=this.input;t&&(t.files=e.dataTransfer.files,t.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!0})),t.dispatchEvent(new Event("change",{bubbles:!0,cancelable:!0}))),this.dispatch("dropped",{detail:{files:e.dataTransfer.files}})}}toggleClass(e,t){t&&this.isDroppable(e)?this.element.classList.add("st-dropzone--dragover"):this.element.classList.remove("st-dropzone--dragover")}overDoc(e){e.preventDefault(),this.isDroppable(e.dataTransfer)&&(this.dragging=!0,this.dragin())}leaveDoc(e){e.preventDefault(),this.isDroppable(e.dataTransfer)&&(this.dragging=!1,this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout(()=>{this.dragging||this.dragout()},200))}dropDoc(e){e.preventDefault(),this.isDroppable(e.dataTransfer)&&(this.dragging=!1,this.dragout())}dragin(){this.element.classList.add("st-dropzone--dragin"),this.growWidthValue&&(this.element.style.minWidth=this.growWidthValue),this.growHeightValue&&(this.element.style.minHeight=this.growHeightValue)}dragout(){this.element.classList.remove("st-dropzone--dragin"),this.growWidthValue&&(this.element.style.minWidth=""),this.growHeightValue&&(this.element.style.minHeight="")}isDroppable(e){return e.items.length&&"file"==e.items[0].kind&&this.isAllowedByInput(e)}isAllowedByInput(e){var t=this.input;return!t||t.hasAttribute("multiple")||1==e.items.length}}t.values={growWidth:String,growHeight:String},t.actions=[["element","dragenter->enter"],["element","dragleave->leave"],["element","drop->drop"],["element","dragover@document->overDoc"],["element","dragleave@document->leaveDoc"],["element","drop@document->dropDoc"]],module.exports=t;
  //# sourceMappingURL=index.js.map
  