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