const t="anj-dragging";class s{constructor(t,s){this.element=t,this.data=s,this.dragStartListener=t=>this.onDragStart(t),this.dragEndListener=t=>this.onDragEnd(t)}connect(){return this.element.setAttribute("draggable","true"),this.element.addEventListener("dragstart",this.dragStartListener),this.element.addEventListener("dragend",this.dragEndListener),this}disconnect(){this.element.removeAttribute("draggable"),this.element.removeEventListener("dragstart",this.dragStartListener),this.element.removeEventListener("dragend",this.dragEndListener)}onDragStart(t){this.element.classList.add("anj-dragging"),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",this.data&&t.dataTransfer.setData("data",JSON.stringify(this.getData())))}onDragEnd(t){t.preventDefault(),this.element.classList.remove("anj-dragging")}getData(){return"function"==typeof this.data?this.data():this.data}}const i="anj-dragover";class r{constructor(t){this.element=t,this.dragEnterListener=()=>this.onDragEnter(),this.dragLeaveListener=()=>this.onDragLeave(),this.dragOverListener=t=>this.onDragOver(t),this.dropListener=t=>this.onDrop(t)}connect(){return this.element.addEventListener("dragenter",this.dragEnterListener),this.element.addEventListener("dragleave",this.dragLeaveListener),this.element.addEventListener("dragover",this.dragOverListener),this.element.addEventListener("drop",this.dropListener),this}disconnect(){this.element.removeEventListener("dragenter",this.dragEnterListener),this.element.removeEventListener("dragleave",this.dragLeaveListener),this.element.removeEventListener("dragover",this.dragOverListener),this.element.removeEventListener("drop",this.dropListener)}onDragEnter(){this.element.classList.add("anj-dragover")}onDragLeave(){this.element.classList.remove("anj-dragover")}onDragOver(t){return t.preventDefault&&t.preventDefault(),this.checkStyle(),t.dataTransfer.dropEffect="move",!1}onDrop(t){if(t.stopPropagation&&t.stopPropagation(),this.element.classList.remove("anj-dragover"),t.dataTransfer&&t.dataTransfer.getData&&t.dataTransfer.getData("data")){const s=JSON.parse(t.dataTransfer.getData("data")),i=new CustomEvent("anjDrop",{detail:s,bubbles:!0});this.element.dispatchEvent(i)}return!1}checkStyle(){this.element.classList.contains("anj-dragover")||this.element.classList.add("anj-dragover")}}export{t as A,s as D,i as a,r as b};