fluid-dnd 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- "use strict";var Ee=Object.defineProperty;var ye=(t,e,n)=>e in t?Ee(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var j=(t,e,n)=>ye(t,typeof e!="symbol"?e+"":e,n);const _="horizontal",et="vertical",U="draggable",Xt="droppable",Mt="handler-class",Ft="dragging",Wt="dragging-handler-class",_t="dropping",oe="grabbing",re="grab",Kt="disable-transition",Ce=(t,e)=>{const n=(l,f)=>t.removeAtEvent(l,f),s=(l,f,g)=>t.insertEvent(l,f,g),o=()=>t.getLength(),r=l=>t.getValue(l),c=l=>l;return{direction:(e==null?void 0:e.direction)??et,handlerSelector:(e==null?void 0:e.handlerSelector)??U,draggingClass:(e==null?void 0:e.draggingClass)??"dragging",droppableClass:(e==null?void 0:e.droppableClass)??"droppable-hover",isDraggable:(e==null?void 0:e.isDraggable)??(()=>!0),onDragStart:(e==null?void 0:e.onDragStart)??(()=>{}),onDragEnd:(e==null?void 0:e.onDragEnd)??(()=>{}),droppableGroup:e==null?void 0:e.droppableGroup,onRemoveAtEvent:n,onInsertEvent:s,onGetLegth:o,onGetValue:r,animationDuration:(e==null?void 0:e.animationDuration)??200,removingClass:(e==null?void 0:e.removingClass)??"removing",insertingFromClass:(e==null?void 0:e.insertingFromClass)??"from-inserting",delayBeforeRemove:(e==null?void 0:e.delayBeforeRemove)??200,delayBeforeInsert:(e==null?void 0:e.delayBeforeInsert)??200,mapFrom:(e==null?void 0:e.mapFrom)??c}},Ae=(t,e)=>{const{config:n,droppable:s}=t,{onInsertEvent:o,onDragEnd:r}=n;return{...n,onDragEnd:f=>{const{index:g,value:m}=f;r({index:g,value:e(m,s)})},onInsertEvent:(f,g)=>o(f,e(g,s),!0)}},st=(t,e)=>t.classList.contains(e),gt=(t,e,n=!1)=>{t.classList.toggle(e,n)},tt=(t,e)=>{t.classList.add(e)},Ct=(t,e)=>{t.classList.remove(e)},xe=(t,e)=>At(e).every(n=>st(t,n)),pt=t=>t?`.${At(t).join(".")}`:"",we=(t,e)=>{if(!e)return;const n=At(e);t.classList.add(...n)},At=t=>t?t.split(" ").filter(e=>e):[],Be=()=>{const{scrollX:t,scrollY:e}=window;return{scrollX:t,scrollY:e}},zt=t=>!t||t.trim().length==0||t=="normal"?0:parseFloat(t),Re=t=>t?parseInt(t):-1,Le=t=>{const e=getComputedStyle(t),n=new DOMMatrixReadOnly(e.transform);return{x:n.m41,y:n.m42}},ie=(t,e)=>t.x1>e.x1?ie(e,t):t.x2<e.x1?0:t.x2>=e.x2?t.x2-t.x1:t.x2-e.x1,ht=(t,e)=>!Me(t,e),Me=(t,e)=>{const n=Ot(t),s=Ot(e),o=Qt(n,s,et),r=Qt(n,s,_);return o>=Math.min(n.height,s.height)/2&&r>=Math.min(n.width,s.width)/2},Qt=(t,e,n)=>{const{before:s,distance:o}=B(n);return ie({x1:t[s],x2:t[s]+t[o]},{x1:e[s],x2:e[s]+e[o]})},M=(t,e)=>t?zt(getComputedStyle(t)[e]):0,Ut=t=>{const{scrollLeft:e,scrollTop:n}=t;return{scrollLeft:e,scrollTop:n}},Ot=t=>t.getBoundingClientRect(),B=t=>{const e=t==_;return{beforeMargin:e?"marginLeft":"marginTop",afterMargin:e?"marginRight":"marginBottom",borderBeforeWidth:e?"borderLeftWidth":"borderTopWidth",before:e?"left":"top",after:e?"right":"down",gap:e?"columnGap":"rowGap",distance:e?"width":"height",axis:e?"x":"y",offset:e?"offsetX":"offsetY",scroll:e?"scrollX":"scrollY",scrollElement:e?"scrollLeft":"scrollTop",page:e?"pageX":"pageY",inner:e?"innerWidth":"innerHeight",offsetElement:e?"offsetLeft":"offsetTop",scrollDistance:e?"scrollWidth":"scrollHeight",clientDistance:e?"clientWidth":"clientHeight",paddingBefore:e?"paddingLeft":"paddingTop",getRect:Ot}},Rt=(t,e)=>Oe(t,e),ce=t=>[...t.children].filter(n=>st(n,U)),Oe=(t,e)=>{const n=[...e.children].filter(o=>st(o,U)&&!o.isEqualNode(t)).toReversed(),s=[...e.children].findLastIndex(o=>o.isEqualNode(t));return[n,s,e]},Ne=t=>{let e=t.parentElement;for(;e;){if(window.getComputedStyle(e).position==="fixed")return e;e=e.parentElement}return null},ae=(t,e)=>{const{before:n,borderBeforeWidth:s}=B(e),o=Ne(t);return o?Ot(o)[n]+M(o,s):0},Tt=t=>window.TouchEvent&&t instanceof TouchEvent,it=t=>t instanceof HTMLElement,le=t=>t instanceof MouseEvent,Fe=["onmouseup","onmousedown","onmousemove"],Pe=(t,e,n)=>{t&&(t.style.height=`${e}px`,t.style.width=`${n}px`)},Et=(t,e,n)=>{!t||!it(t)||(n==0&&e==0?t.style.transform="":t.style.transform=`translate(${n}px,${e}px)`)},$e=(t,e,n,s)=>{t[e]=o=>{if(o.defaultPrevented)return;s&&s(o);const r=Vt(o);n(r)}},It=(t,e,n,s)=>{n&&(Ge(e)?t[e]=n:$e(t,e,n,s))},Ge=t=>Fe.includes(t),Ie=t=>{const{target:e}=t;return{clientX:0,clientY:0,pageX:0,pageY:0,screenX:0,screenY:0,target:e,offsetX:0,offsetY:0}},Ye=(t,e)=>{const n=(s,o)=>We(e,window,o,s);if(le(t)){const{offsetX:s,offsetY:o}=t;return[s,o]}else{const s=t.target;return[n(s,_),n(s,et)]}},Vt=t=>{const e=Xe(t);if(!e)return Ie(t);const[n,s]=Ye(t,e),{clientX:o,clientY:r,pageX:c,pageY:l,screenX:f,screenY:g,target:m}=e;return{clientX:o,clientY:r,pageX:c,pageY:l,screenX:f,screenY:g,target:m,offsetX:n,offsetY:s}},Xe=t=>{if(Tt(t))return t.touches[0]??t.changedTouches[0];if(le(t))return t},We=(t,e,n,s)=>{const{page:o,scroll:r,before:c,borderBeforeWidth:l,getRect:f}=B(n),g=f(s);return t[o]-e[r]-g[c]-M(s,l)},Pt=(t,e,n="ease-out",s="transform")=>{it(t)&&(t.style.transitionDuration=`${e}ms`,t.style.transitionTimingFunction=`${n}`,t.style.transitionProperty=`${s}`)},ue=(t,e,n)=>{!t||!it(t)||(t[e]=()=>{n()})},_e=t=>{var e=t.querySelector("style");if(!e){var n=document.createElement("style");return t.appendChild(n),n}return e},Ve=(t,e)=>{const n=/\.-?[_a-zA-Z0-9-*\s<>():]+/g,[s]=e.match(n)||[];for(const o of t.cssRules){const[r]=o.cssText.match(n)||[];if(s===r)return!0}return!1},He=(t,e)=>{e.forEach(n=>{qe(t,n)})},qe=(t,e)=>{var s;var n=_e(t);n.sheet&&(Ve(n.sheet,e)||(s=n.sheet)==null||s.insertRule(e,n.sheet.cssRules.length))},fe=(t,e={})=>{for(const n of Object.keys(e)){const s=e[n];s!=null&&ze(t,`--${n}`,s)}},ze=(t,e,n)=>t&&t.style.setProperty(e,n),je=(t,e,n)=>{n!=0&&(e==="vertical"?t.scrollBy(0,n):t.scrollBy(n,0))},Ze=(t,e,n)=>{const{scrollDistance:s,clientDistance:o,scrollElement:r}=B(t);return n[r]/(e[s]-e[o])},ke=t=>{let e={offsetX:0,offsetY:0},n={top:0,left:0},s={x:0,y:0};const o=f=>{t.style.transform=`translate( ${f.x}px, ${f.y}px)`},r=f=>{t.style.top=`${f.top}px`,t.style.left=`${f.left}px`};return[(f,g,m,b)=>{const R=y=>{const{beforeMargin:p,borderBeforeWidth:E,before:L,offset:w,scroll:P,page:X,inner:Z,distance:V,axis:H,getRect:$}=B(y),k=m[X],q=window[P],J=window[Z],I=$(f)[V],z=M(f,E),W=M(f,p),Y=k-e[w],nt=ae(f,y);if(Y>=q-I/2&&Y<=q+J){const ot=Y-n[L]-z-W-q-nt;return O(y),ot}return s[H]},O=y=>{if(f&&st(f,Ft)&&y===b){const{before:p,distance:E,axis:L,getRect:w}=B(b),P=w(f)[E],X=w(g),Z=n[p]-X[p]+s[L],H=X[E]-P,$=Z/H,k=P/H,q=.1,J=.2,I=.8;let z=0;const W=ht(f,g);!W&&$<J&&$>-k?z=$/J-1:!W&&$>I&&$<1+k&&(z=1/(1-I)*($-I));const Y=q*P*z;je(g,b,Y)}},F=y=>{const{axis:p}=B(y);s[p]=R(y),o(s)};F(_),F(et)},(f,g)=>{const[m,b,R,O]=Qe(f,g,t);n={top:m,left:b},r(n),e={offsetX:R,offsetY:O}}]},Lt=(t,e,n)=>{const{borderBeforeWidth:s,before:o,getRect:r}=B(t);return r(e)[o]-r(n)[o]-M(n,s)},Je=(t,e)=>{let{offsetX:n,offsetY:s,target:o}=t,r=Ke(o,e);const c=o;return c&&r&&!c.isSameNode(r)&&(n+=Lt(_,c,r),s+=Lt(et,c,r)),r&&e!=o&&(n+=Lt(_,r,e),s+=Lt(et,r,e)),[n,s]},Ke=(t,e)=>{const n=t==null?void 0:t.closest(`.${Mt}`);return n&&n.isSameNode(e)?t:n},te=(t,e,n,s)=>{const{offset:o,beforeMargin:r,page:c,borderBeforeWidth:l,scroll:f}=B(t),g=ae(n,t);return e[c]-s[o]-M(n,r)-M(n,l)-window[f]-g},Qe=(t,e,n)=>{const[s,o]=Je(t,n);return[te(et,t,e,{offsetX:s,offsetY:o}),te(_,t,e,{offsetX:s,offsetY:o}),s,o]},de="startDrag",Nt="drag",jt="startDrop",Ue="drop",at="temp-child",ge="cubic-bezier(0.2, 0, 0, 1)",tn=t=>t===Ue||t===jt,Ht=t=>!t||t.length==0?0:zt(t.replace("px","")),en=(t,e)=>{const n=getComputedStyle(t)[e];if(n.match("%")){const o=zt(n.replace("%","")),{width:r}=t.getBoundingClientRect();return r*(o/100)}return Ht(n)},Zt=(t,e)=>{if(!(t instanceof Element))return[0,!1];const n=en(t,e),s=getComputedStyle(t).display,o=n>0||s==="flex";return[n,o]},nn=t=>{const{top:e,left:n}=getComputedStyle(t);return[Ht(e),Ht(n)]},sn=(t,e)=>{const{gap:n}=B(e),[s,o]=Zt(t,n);return o?s:0};function yt(t,e,n,s,o=t.previousElementSibling,r=t.nextElementSibling){let{height:c,width:l}=on(n,t,o,r);return ht(t,s)&&e==Nt&&(c=0,l=0),{height:c,width:l}}const on=(t,e,n,s)=>{const{afterMargin:o,beforeMargin:r,distance:c,gap:l,getRect:f}=B(t),g=M(e,o),m=M(e,r),b=M(s,r),[R,O]=Zt(e.parentElement,l),F=f(e)[c];if(O)return ee(F,m,g,R,0,t);const[y,p,E]=rn(n,b,g,m,o);return ee(F,p,y,0,E,t)},rn=(t,e,n,s,o)=>{const r=Math.max(e,n);let c=s,l=e;if(t){const f=M(t,o);c=Math.max(f,s),l=Math.max(l,f)}return[r,c,l]},ee=(t,e,n,s,o,r)=>cn(r,t+e+n+s-o),cn=(t,e)=>t==_?{width:e,height:0}:{width:0,height:e},ne=(t,e)=>{const{borderBeforeWidth:n,paddingBefore:s,axis:o,getRect:r}=B(t),c=M(e,n),l=M(e,s),f=r(e)[o];return c+l+f},an=(t,e)=>{const[n,s]=nn(e),o=ne(et,t);return[ne(_,t)-s,o-n]};function ln(t,e,n,s,o,r,c,l,f){let g=0,m=0;const b=!!(n<0&&f);if(n===s&&!b)return se({height:g,width:m},t,o,c,b);const[R,O,F,y]=dn(e,n,s,f);if(b){const[nt,ut]=an(l,f);g+=ut,m+=nt}const{scrollElement:p,beforeMargin:E,afterMargin:L,distance:w,gap:P}=B(t),[X,Z]=Zt(l,P),[V,H,$]=pn(E,L,R,O==null?void 0:O.previousElementSibling,y,Z,b),[k,q,J]=gn(E,L,w,F,X,Z),I=fn(q,k,J,H,V,X),z=b?l[p]:un(p,l,r),Y=(y?I-$:$-I)-z;return t===et?g+=Y:t===_&&(m+=Y),se({height:g,width:m},t,o,c,b)}const un=(t,e,n)=>{const s=e[t],o=n[t];return s-o},fn=(t,e,n,s,o,r)=>{const c=Math.max(e,o);return Math.max(n,s)+t+c+r},dn=(t,e,n,s)=>{const o=e<n,[r,c]=[e,n].toSorted((m,b)=>m-b),l=t[e]??s,f=t[n];let g=o?t.slice(r+1,c+1):t.slice(r,c);return r<0&&s&&(g=t.slice(r+1,c)),[l,f,g,o]},gn=(t,e,n,s,o,r)=>{if(s.length==0)return[0,0,0];const c=M(s[0],t);let l=0,f=-c;for(const[g,m]of s.entries()){const b=m.getBoundingClientRect()[n],R=M(m,t);r&&(l+=R),r&&g>0?l+=o:l=Math.max(l,R),f+=l+b,l=M(m,e)}return[c,f,l]},se=(t,e,n,s,o)=>{const{scroll:r,distance:c}=B(e),l=window[r],f=n[r],g=o?0:f-2*l+s[r];return t[c]+=g,t},pn=(t,e,n,s,o,r,c)=>{const l=o?n.previousElementSibling:s;return hn(t,e,l,n,r,c)},hn=(t,e,n,s,o,r)=>{if(o)return[0,0,0];const c=M(r?null:n,e),l=M(s,t);let f=Math.max(c,l);return[c,l,f]},kt=(t,e,n,s=()=>!0)=>{const o=new MutationObserver(r=>{if(r=r.filter(s),r.length>0){const c=r[0];t(o,c)}});return o.observe(e,n),o},mn="startDrag",pe="cubic-bezier(0.2, 0, 0, 1)",he=50,qt=t=>it(t)?t.classList.contains(at):!1,Sn=(t,e,n)=>{let s=yt(e,mn,n,t);const o=sn(t,n),{distance:r}=B(n);s[r]-=o;const[c,l]=Dn(n,e);return s[l]=c,s},Dn=(t,e)=>{const n=t==_?et:_,{distance:s,getRect:o}=B(n);return[o(e)[s],s]},mt=(t,e,n)=>{Pe(t,e,n),t.style.minWidth=`${n}px`},vn=(t,e,n)=>s=>{e.contains(t)&&(mt(t,n.height,n.width),s.disconnect())},bn=(t,e)=>{if(!e)return;const{droppable:n,config:s,scroll:o}=t,{direction:r}=s,c=Ze(s.direction,n,o)>.99,{scrollDistance:l,clientDistance:f,scrollElement:g}=B(r);c&&(n[g]=n[l]-n[f])},me=(t,e,n,s)=>{if(!n)return;const{droppable:o,config:r}=n,{direction:c,animationDuration:l}=r;if(bn(n,e),o.querySelector(`.${at}`)||!t)return;var f=t.tagName=="LI"?"DIV":t.tagName,g=document.createElement(f);tt(g,at),mt(g,0,0);const m=Sn(o,t,c);return Pt(g,l,pe,"width, min-width, height"),[g,m,o]},Yt=(t,e,n,s,o)=>{const r=me(t,n,s);if(!r)return;const[c,l,f]=r;e.isSameNode(f)&&mt(c,l.height,l.width),kt(vn(c,f,l),f,{childList:!0,subtree:!0}),f.appendChild(c)},Tn=(t,e,n)=>{const s=me(t,e,n);if(!s)return;const[o,r,c]=s;c.appendChild(o),En(o,r)},En=(t,e)=>requestAnimationFrame(()=>{mt(t,e.height,e.width),requestAnimationFrame(()=>{Pt(t,0,pe,"width, min-width, height")})}),yn=(t,e,n,s,o=!0)=>{if(n){var r=document.querySelectorAll(`${pt(n)} > .${at}`);r.forEach(c=>{const l=c.parentElement;if(l!=null&&l.isSameNode(e)||!o&&(l!=null&&l.isSameNode(t)))return;mt(c,0,0),setTimeout(()=>{var g;(g=c.parentNode)==null||g.removeChild(c)},s+he)})}},bt=(t,e,n=!1)=>{var s=t.querySelectorAll(`.${at}`);s.forEach(o=>{const r=o;n?(mt(r,0,0),setTimeout(()=>{t.contains(r)&&t.removeChild(r)},e+he)):t.removeChild(o)})},Cn=50;function An(t,e,n,s,o,r){let c=e;const{direction:l,handlerSelector:f,onRemoveAtEvent:g,animationDuration:m,delayBeforeInsert:b,draggingClass:R}=t,O=(u,a,h,D,C)=>{if(!D)return;const{droppable:T,config:v}=D,A=yt(u,a,v.direction,T);tn(a)?Z(u,a,A,h,D,C):E(u,a,A,D)},F=(u,a,h,D,C)=>{const T=yt(a,"insert",t.direction,h),{onInsertEvent:v}=t,A=ce(h);for(const[N,x]of A.entries())st(x,U)&&N>=u&&X(x,T);C(),setTimeout(()=>{v(u,D),Se(u,h,t),nt(a),W(a,n),bt(n,0,!0)},b)},y=(u,a,h,D)=>{if(!h||!h.droppable||!h.config)return;const{droppable:C,config:T}=h;let[v]=Rt(a,C);v=[a,...v].toReversed();const A=yt(a,"remove",T.direction,C);for(const[N,x]of v.entries())N>=u&&(P(x,A),setTimeout(()=>{D(x)},m))},p=u=>{bt(n,m,!0),setTimeout(()=>{nt(u),W(u,n)},m)},E=(u,a,h,D)=>{const{config:C,droppable:T}=D,[v]=Rt(u,T),A=ht(u,T);v.length==0&&w(h,1,C.direction,v);for(const[N,x]of v.entries()){if(!st(x,U))continue;const G=L(C.direction,u,x,h);if(!A&&G)h=G;else if(!A)continue;const K=v.length-N;w(h,K,C.direction,v),a===de?P(x,h):a===Nt&&X(x,h)}},L=(u,a,h,D)=>{const{before:C,distance:T,axis:v,getRect:A}=B(u),N=A(a),x=A(h),G=N[C],K=x[C],St=x[T],ft=K+St/2,Dt=Le(h)[v],rt=ft-Dt;return G>rt?{height:0,width:0}:D},w=(u,a,h,D)=>{const C=D.filter(v=>st(v,U)).length,{distance:T}=B(h);u[T]==0?c=Math.max(c,a):c=Math.min(c,a-1),c=Math.min(c,C)},P=(u,a)=>{const{width:h,height:D}=a;Et(u,D,h)},X=(u,a)=>{const{width:h,height:D}=a;Et(u,D,h),Pt(u,m,ge)},Z=(u,a,h,D,C,T)=>{const{droppable:v,scroll:A,config:N}=C,[x,G]=Rt(u,v),K=x.toReversed(),St=G===-1?K.length:G;K.splice(St,0,u);const[ft,Dt,rt]=V(u,G,K,v);h=yt(u,a,N.direction,n,ft,Dt);const $t=Be(),xt=ln(N.direction,K,G,rt,$t,A,D,v,u);x.length==0&&H(void 0,h,u,xt);for(const[Gt,wt]of x.toReversed().entries()){let Bt=h;rt-1>=Gt&&(Bt={height:0,width:0}),a===jt&&!st(wt,at)&&H(wt,Bt,u,xt)}$(rt,u,N,v,T)},V=(u,a,h,D)=>{const T=ht(u,D)?a:c,v=()=>a<T?[T,T+1]:a>T?[T-1,T]:[T-1,T+1],[A,N]=v(),x=h[A]??null,G=h[N]??null;return[x,G,T]},H=(u,a,h,D)=>{Et(u,a.height,a.width),Et(h,D.height,D.width)},$=(u,a,h,D,C)=>{const{onInsertEvent:T,onDragEnd:v}=h;tt(a,_t),J(a,n,D,()=>{if(Ct(a,_t),C!=null){const A=g(C,!0);A!=null&&(T(u,A,!0),v({value:A,index:u})),q(a),k()}})},k=()=>{if(s){var u=document.querySelectorAll(`${pt(s)} > .${U}`);for(const a of u)Y(a)}},q=u=>{setTimeout(()=>{Ct(u,R)},Cn)},J=(u,a,h,D)=>{setTimeout(()=>{D&&D(),I(a,h),z(h),nt(u),W(u,a),W(u,h)},m)},I=(u,a)=>{u.isSameNode(a)?bt(u,m):(bt(u,m,!0),bt(a,m))},z=u=>{if(n.isSameNode(u))return;var[a]=n.querySelectorAll(`.${at}`);if(!a)return;const{distance:h}=B(l);it(a)&&(a.style[h]="0px")},W=(u,a)=>{const[h]=Rt(u,a);for(const D of[...h,u])Y(D)},Y=u=>{it(u)&&(u.style.transition="",u.style.transform="")},nt=u=>{r(),ot(u,!1),u.style.transform="",u.style.transition="",u.style.top="",u.style.left="",fe(u,{fixedHeight:"",fixedWidth:""})},ut=(u,a)=>{const h=a.querySelector(f);gt(document.body,oe,u),gt(h||a,Wt,u)},ot=(u,a)=>{gt(u,Ft,a),ut(a,u),o.toggleGrabClass(!a)};return[O,y,F,p,ot]}const xn=t=>t.addedNodes.values().filter(n=>!qt(n)).toArray().length>0,Se=(t,e,n)=>{const{insertingFromClass:s,animationDuration:o}=n,r=kt(()=>{const l=ce(e)[t];tt(l,s),tt(l,Kt),setTimeout(()=>{Ct(l,Kt),Ct(l,s),r.disconnect()},o)},e,{childList:!0},xn)},wn=(t,e,n,s)=>{if(!e)return;const{onInsertEvent:o,delayBeforeInsert:r}=t;setTimeout(()=>{o(n,s),Se(n,e,t)},r)},Q=class Q{static addConfig(e,n){const s=Q.configs.filter(r=>!r.droppable.isSameNode(e)),o=Ut(e);s.push({droppable:e,config:n,scroll:o}),Q.configs=s}static updateScrolls(e,n){for(const s of Q.configs){const{droppable:o}=s;(n&&xe(o,n)||o.isSameNode(e))&&(s.scroll=Ut(o))}}static getConfig(e){return Q.configs.find(({droppable:s})=>s.isSameNode(e))}};j(Q,"configs",[]),j(Q,"removeObsoleteConfigs",()=>{const e=Q.configs.filter(({droppable:n})=>document.contains(n));Q.configs=e});let lt=Q;class Bn{constructor(e,n,s,o,r,c){j(this,"initial");j(this,"current");j(this,"parent");j(this,"draggableElement");j(this,"groupClass");j(this,"dragEvent");j(this,"changeDroppable");j(this,"mapFrom");this.parent=s,this.draggableElement=e,this.groupClass=n,this.dragEvent=o,this.mapFrom=c,this.initial=s?lt.getConfig(s):void 0,this.changeDroppable=r}getDraggableAncestor(e,n,s){return document.elementsFromPoint(e,n).filter(o=>!o.isSameNode(s))}getElementBelow(e,n,s=!0){const o=c=>{const[l]=c.getDraggableAncestor(n.clientX,n.clientY,e);return l};let r=null;return s?(e.hidden=!0,r=o(this),e.hidden=!1):r=o(this),r}getCurrent(e,n,s=!0){const o=this.getElementBelow(e,n,s);return!this.groupClass||!o?void 0:o.closest(pt(this.groupClass))}isOutsideOfAllDroppables(e){return(this.groupClass?Array.from(document.querySelectorAll(pt(this.groupClass))):[this.parent]).every(s=>ht(e,s))}isNotInsideAnotherDroppable(e,n){return!ht(e,n)||this.isOutsideOfAllDroppables(e)}onScrollEvent(){this.dragEvent()}setOnScroll(e){ue(e,"onscroll",()=>{this.onScrollEvent()})}getConfigFrom(e){const n=lt.getConfig(e);if(n)return e.isSameNode(this.parent)?n:{...n,config:Ae(n,this.mapFrom)}}getCurrentConfig(e){var o;const n=this.draggableElement;if(this.current&&this.isNotInsideAnotherDroppable(n,(o=this.current)==null?void 0:o.droppable))return this.current;const s=this.getCurrent(n,e);return s?(it(s)&&!s.onscroll&&this.setOnScroll(s),this.getConfigFrom(s)):this.getConfigFrom(this.parent)}updateConfig(e){const n=this.current;this.current=this.getCurrentConfig(e),this.changeDroppable(this.current,n)}isOutside(e,n=!0){const s=this.draggableElement;return!this.getCurrent(s,e,n)}}function Rn(t,e,n,s,o){const{handlerSelector:r,isDraggable:c,droppableGroup:l,animationDuration:f,delayBeforeRemove:g,draggingClass:m,removingClass:b,onRemoveAtEvent:R,droppableClass:O,onDragStart:F}=n,y=At(l).map(i=>`droppable-group-${i}`).join(" ");let p=0,E={scrollX:0,scrollY:0},L={pageX:0,pageY:0},w,P;const[X,Z]=ke(t),[V,H,$,k,q]=An(n,e,s,y,o,()=>p=0),J=()=>{tt(t,U)},I=i=>{tt(i,Mt),o.addSubscriber(i)},z=()=>{if(c(t)){const i=t.querySelector(r);I(i||t)}},W=()=>{z(),J()},Y=i=>{const d=i==null?void 0:i.querySelector(`.${Mt}`),S=d==null?void 0:d.parentElement;return d&&S&&st(S,Xt)&&!S.isSameNode(s)?null:d},nt=i=>{const d=Y(i)??i;d&&c(i)&&(It(d,"onmousedown",G("mousemove","mouseup")),It(d,"ontouchstart",G("touchmove","touchend"),S=>{P={x:S.touches[0].clientX,y:S.touches[0].clientY}}),ut(d)),i!=null&&i.isSameNode(d)||It(i,"onmousedown",K),tt(s,Xt)},ut=i=>{const d=i.querySelectorAll("img");Array.from(d).forEach(S=>{S.onmousedown=()=>!1})},ot=()=>{if(L.pageX==0&&L.pageY==0||!a.current)return;const{droppable:i,config:d}=a.current;X(t,i,L,d.direction),V(t,Nt,E,a.current)},u=(i,d)=>{d&&p==2&&!(i!=null&&i.droppable.isSameNode(d.droppable))&&V(t,Nt,E,d)},a=new Bn(t,y,s,ot,u,n.mapFrom),h=i=>{if(!a.current)return;const d=y?Array.from(document.querySelectorAll(pt(y))):[s];for(const S of d)S.classList.toggle(O,!i&&S.isSameNode(a.current.droppable))},D=(i,d=!1)=>{a.updateConfig(i);const S=a.isOutside(i);h(S),p===1&&!d?rt(i):p===2&&(C(S),xt(i))},C=(i=!0)=>{if(!a.current)return;const{droppable:d}=a.current;yn(d,s,y,f,i),!i&&Yt(t,s,p==1,a.current)},T=i=>{if(Tt(i)&&P&&p==1){const d=Math.abs(i.touches[0].clientX-P.x),S=Math.abs(i.touches[0].clientY-P.y);if(Math.abs(d)>5&&Math.abs(S)>5)return clearTimeout(w),!1}return!0},v=i=>{clearTimeout(w);const d=Vt(i);if(Tt(i)&&i.cancelable&&i.preventDefault(),Tt(i)&&!i.cancelable||!T(i)){ft("touchmove",i);return}D(d,Tt(i))},A=(i,d)=>{i=="touchmove"?w=setTimeout(()=>{d()},150):d()},N=(i,d)=>{const{clientX:S,clientY:dt}=i,ct=document.elementFromPoint(S,dt),vt=ct==null?void 0:ct.closest(`.${U}`);return vt&&d.isSameNode(vt)},x=i=>{const d=n.onGetValue(e);return{index:e,element:i,value:d}},G=(i,d)=>S=>{if(!N(S,t))return;lt.updateScrolls(s,y);const{scrollX:dt,scrollY:ct}=window;if(E={scrollX:dt,scrollY:ct},p===0){p=1;const vt=x(t);vt&&F(vt),A(i,()=>{i=="touchmove"&&(a.updateConfig(S),h(a.isOutside(S)),rt(S))}),document.addEventListener(i,v,{passive:!1}),Gt(s),document.addEventListener(d,St(i),{once:!0})}},K=i=>a.updateConfig(i),St=i=>d=>{ft(i,d)},ft=(i,d)=>{h(!0);const S=Vt(d);Bt(a.isOutside(S,!1)),clearTimeout(w),document.removeEventListener(i,v),a.updateConfig(S);const dt=a.getCurrentConfig(S);if(dt){const{droppable:ct}=dt;Dt(ct)}s.onscroll=null},Dt=i=>{if(i.onscroll=null,!y)return;const d=Array.from(document.querySelectorAll(pt(y)));for(const S of d)it(S)&&(S.onscroll=null)},rt=i=>{Yt(t,s,p==1,a.current),$t(),V(t,de,E,a.current),De(t),Z(i,t)},$t=()=>{p=2},xt=i=>{const{pageX:d,pageY:S}=i;L={pageX:d,pageY:S},ot()},Gt=i=>ue(i,"onscroll",wt),wt=()=>ot(),Bt=i=>{if(p!==2&&p!==1){p=0;return}p=3,Jt(t),t.classList.contains(Ft)&&V(t,jt,E,i?a.initial:a.current,e)},Jt=i=>{Pt(i,f,ge),Et(i,0,0)},De=i=>{const{height:d,width:S}=i.getBoundingClientRect();fe(i,{fixedHeight:`${d}px`,fixedWidth:`${S}px`}),q(i,!0),gt(i,m,!0),i.style.transition=""},ve=(i,d)=>{Ct(t,b),Yt(t,s,p==1,a.initial),H(i,t,d,S=>{Jt(S),k(t)}),R(e,!0)},be=i=>{if(!a.initial)return;const d=a.initial;i==e&&(tt(t,b),setTimeout(()=>{ve(i,d)},g))},Te=(i,d)=>{(i===e||i===n.onGetLegth()&&e===i-1)&&$(i,t,s,d,()=>{Tn(t,p==1,a.initial)})};return W(),nt(t),[be,Te]}const Ln=(t,e)=>{t&&we(e,t)},Mn=()=>{He(document.body,[`.${U}{touch-action:manipulation;user-select:none;box-sizing:border-box!important;-webkit-user-select:none;}`,`.${Mt}{pointer-events:auto!important;}`,`.${re}{cursor:grab;}`,".temp-child{touch-action:none;pointer-events:none;box-sizing:border-box!important;}",".droppable{box-sizing:border-box!important;}",`.${Ft}{position:fixed;z-index:5000;width:var(--fixedWidth)!important;height:var(--fixedHeight)!important;}`,`.${Wt}{pointer-events:none!important;}`,`.${_t}{pointer-events:none!important;}`,`.${oe}{cursor:grabbing;}`,".disable-transition{transition:none!important;}"])};function On(t,e,n,s="index"){const o=s;let r=[],c=[];const{droppableGroup:l}=t;if(!n)return[r,c];const f=At(l).map(g=>`droppable-group-${g}`).join(" ");Mn(),Ln(f,n);for(const g of n.children){const m=g.getAttribute(o),b=Re(m),R=g;if(R&&b>=0){const[O,F]=Rn(R,b,t,n,e);r.push(O),c.push(F)}}return[r,c]}function Nn(t,e,n,s="index"){let o=[],r=[],c;const l=Ce(t,n),f=p=>{for(const E of o)E(p)},g=(p,E)=>{if(l.onGetLegth()===0)t.insertToListEmpty(l,p,E);else for(const w of r)w(p,E)},m=p=>{const[E,L]=On(l,e,p,s);o=E,r=L},b=p=>{const E=p.addedNodes.values().filter(w=>!qt(w)).toArray(),L=p.removedNodes.values().filter(w=>!qt(w)).toArray();return E.length>0||L.length>0},R=p=>{c=kt(()=>{m(p)},p,{childList:!0},b)},O=p=>{tt(p,Xt)},F=p=>{lt.addConfig(p,l)};return[f,g,p=>{if(p)return O(p),F(p),R(p),m(p),lt.removeObsoleteConfigs(),c}]}exports.GRAB_CLASS=re;exports.addClass=tt;exports.dragAndDrop=Nn;exports.insertToListEmpty=wn;exports.toggleClass=gt;