import{c as L,m as M,n as y,v as R,L as A,E as I,M as O,y as _,A as z,w as F}from"./index-1428e3a1.js";import{b as V}from"./function-call-215ccdbc.js";import{u as X}from"./use-expose-e42a8a37.js";import{d as $,r as m,B as j,a as x,c as v}from"./index-234c814f.js";import{c as q}from"./on-popup-reopen-29631c54.js";const[G,p]=L("swipe-cell"),J={name:M(""),disabled:Boolean,leftWidth:y,rightWidth:y,beforeClose:Function,stopPropagation:Boolean};var K=$({name:G,props:J,emits:["open","close","click"],setup(t,{emit:i,slots:r}){let n,c,f;const u=m(),C=m(),k=m(),o=j({offset:0,dragging:!1}),l=V(),w=e=>e.value?O(e).width:0,d=x(()=>R(t.leftWidth)?+t.leftWidth:w(C)),g=x(()=>R(t.rightWidth)?+t.rightWidth:w(k)),T=e=>{o.offset=e==="left"?d.value:-g.value,n||(n=!0,i("open",{name:t.name,position:e}))},h=e=>{o.offset=0,n&&(n=!1,i("close",{name:t.name,position:e}))},B=e=>{const a=Math.abs(o.offset),s=.15,N=n?1-s:s,S=e==="left"?d.value:g.value;S&&a>S*N?T(e):h(e)},D=e=>{t.disabled||(f=o.offset,l.start(e))},H=e=>{if(t.disabled)return;const{deltaX:a}=l;l.move(e),l.isHorizontal()&&(c=!0,o.dragging=!0,(!n||a.value*f<0)&&_(e,t.stopPropagation),o.offset=z(a.value+f,-g.value,d.value))},W=()=>{o.dragging&&(o.dragging=!1,B(o.offset>0?"left":"right"),setTimeout(()=>{c=!1},0))},b=(e="outside")=>{i("click",e),n&&!c&&q(t.beforeClose,{args:[{name:t.name,position:e}],done:()=>h(e)})},E=(e,a)=>s=>{a&&s.stopPropagation(),b(e)},P=(e,a)=>{const s=r[e];if(s)return v("div",{ref:a,class:p(e),onClick:E(e,!0)},[s()])};return X({open:T,close:h}),A(u,()=>b("outside"),{eventName:"touchstart"}),I("touchmove",H,{target:u}),()=>{var e;const a={transform:`translate3d(${o.offset}px, 0, 0)`,transitionDuration:o.dragging?"0s":".6s"};return v("div",{ref:u,class:p(),onClick:E("cell",c),onTouchstartPassive:D,onTouchend:W,onTouchcancel:W},[v("div",{class:p("wrapper"),style:a},[P("left",C),(e=r.default)==null?void 0:e.call(r),P("right",k)])])}}});const te=F(K);export{te as S};