import{N as a,n,R as e,f as r,_ as t,g as l,d as o,a as u,c as s,k as i,i as c,l as f}from"../../vendor.js";import{forwardRef as v,useState as g,useEffect as d,Children as p,cloneElement as D}from"react";var m=["className","children","disabled","onDrop","onDragOver","onDragLeave"];function b(a,n){var e=i(a);if(c){var r=c(a);n&&(r=f(r).call(r,(function(n){return s(a,n).enumerable}))),e.push.apply(e,r)}return e}function h(a){for(var n=1;n<arguments.length;n++){var e,i=null!=arguments[n]?arguments[n]:{};if(n%2)r(e=b(Object(i),!0)).call(e,(function(n){t(a,n,i[n])}));else if(l)o(a,l(i));else{var c;r(c=b(Object(i))).call(c,(function(n){u(a,n,s(i,n))}))}}return a}var N=v((function(r,t){var l=r.className,o=r.children,u=r.disabled,s=void 0!==u&&u,i=r.onDrop,c=r.onDragOver,f=r.onDragLeave,v=a(r,m),b=g(!1),N=n(b,2),O=N[0],j=N[1],L=g(0),x=n(L,2),y=x[0],R=x[1],T=g(null),Y=n(T,2),k=Y[0],B=Y[1];d((function(){y<=0&&j(!1)}),[y]);var C=p.only(o);return D(C,h(h({},v),{},{ref:t,className:e(l,C.props.className,{"drag-enter":!s&&O},{"drag-top":!s&&O&&k&&"before"===k},{"drag-bottom":!s&&O&&k&&"after"===k}),onDragEnter:function(){s||(R(y+1),j(!0))},onDragLeave:function(a){s||(R(y-1),B(null),null==f||f(a))},onDrop:function(a){s||(R(0),j(!1),null==i||i(JSON.parse(a.dataTransfer.getData("text")),k,a),a.preventDefault(),B(null))},onDragOver:function(a){var n,e=a.currentTarget.getBoundingClientRect(),r=(null==e?void 0:e.top)+(null==e?void 0:e.height)/2;return a.clientY>=r?n="after":a.clientY<r&&(n="before"),B(n),a.preventDefault(),null==c||c(a,n),!1}}))}));export{N as D};
//# sourceMappingURL=index.js.map
