import W from"./DKUQAchG.js";import{b4 as p,d as k,r as a,e as C,bA as O,f as j,i as E,h as N,bi as V,z as h,A as b,$ as q,g as S,o as P,_ as F}from"./BxiWQxwE.js";const G=()=>{const c=p("isScrolling",()=>!1),v=p("isDragging",()=>!1);return{isScrolling:c,isDragging:v}},H=()=>({undoDragId:p("undo-drag-id",()=>null)}),J=k({__name:"drag-container",props:{rightDrag:{type:Boolean,default:!1},leftDrag:{type:Boolean,default:!0},id:{type:String,required:!1,default:"-1"}},emits:["dragged"],setup(c,{emit:v}){const{isScrolling:$,isDragging:_}=G(),o=c,s=a(""),d=a(!1),D=a(!1),f=a(!1),g=a(!1),i=a(0),m=a(0),l=a(0),y=a(0),e=a(),x=C(()=>`--move-amount: ${Math.abs(l.value)}; --undo-amount: ${d.value?Math.abs(l.value):0};`),z=v,B=r=>{if(!e.value)return;f.value=!0,setTimeout(()=>{f.value=!1,g.value=$.value},100);const[t]=r.touches;m.value=t.pageX,y.value=Date.now()/1e3,i.value=Math.round(t.clientX||t.pageX),e.value.style.transition="none"},A=r=>{if(f.value||g.value||!e.value)return;_.value=!0;const[t]=r.touches,n=Math.round(t.clientX||t.pageX),u=t.pageX-m.value;o.rightDrag&&o.leftDrag?l.value=n-i.value:o.rightDrag?l.value=Math.max(0,n-i.value):o.leftDrag&&(l.value=Math.min(0,n-i.value)),o.rightDrag&&u>0?s.value="right":s.value="left",e.value.style.transform=`translateX(${l.value}px)`},I=r=>{if(!e.value)return;const[t]=r.changedTouches,n=Math.round(t.clientX||t.pageX);let u=!1;s.value==="right"?u=window.innerWidth/2<n-i.value:u=window.innerWidth/2<Math.abs(n-i.value);const w=Date.now()/1e3-y.value,M=u?1e3:400,T=Math.round(w*1e3)<M?Math.round(w*1e3):M;e.value.style.transition=`transform ${T}ms cubic-bezier(0.25, 1, 0.5, 1)`,u?e.value.style.transform=`translateX(${s.value==="left"?-window.innerWidth:window.innerWidth}px)`:(e.value.style.transform="translateX(0)",d.value=!0),m.value=0,l.value=0,g.value=!1,_.value=!1,setTimeout(()=>{e.value&&(s.value="",e.value.style.transition="",u?(z("dragged",{direction:s.value,id:o.id}),D.value=!0):d.value&&(D.value=!1,e.value.style.transform="translateX(0)"),d.value=!1)},T)},{undoDragId:X}=H();return O(()=>{X.value===o.id&&e.value&&(e.value.style.transform="translateX(0)",X.value=null)}),(r,t)=>{const n=W;return P(),j("div",{class:b(["drag",S(s)]),style:q(S(x))},[E(n,{class:"trash"}),N("div",{ref_key:"container",ref:e,class:b(`drag-container drag_container__${c.id}`),onTouchstart:h(B,["stop"]),onTouchmove:h(A,["stop"]),onTouchend:h(I,["stop"])},[V(r.$slots,"default",{},void 0,!0)],34)],6)}}}),K=F(J,[["__scopeId","data-v-4dc99b41"]]),U=Object.freeze(Object.defineProperty({__proto__:null,default:K},Symbol.toStringTag,{value:"Module"}));export{K as _,U as d,H as u};
