import{c as j,t as A,n as K,b as D,d as q,r as L,x as F,u as re,a9 as ve,e as d,X as G,w as z,b6 as fe,b7 as de,aW as he,y as J,ay as ge,aI as we,az as me,av as be,Y as ye,a as I,bB as U,z as Q,aK as E,p as Se,_ as B,k as Z,ac as pe}from"./index-74aaacd7.js";const[ee,k]=j("swipe"),xe={loop:A,width:K,height:K,vertical:Boolean,autoplay:D(0),duration:D(500),touchable:A,lazyRender:Boolean,initialSwipe:D(0),indicatorColor:String,showIndicators:A,stopPropagation:A},te=Symbol(ee);var Te=q({name:ee,props:xe,emits:["change","dragStart","dragEnd"],setup(a,{emit:y,slots:g}){const u=L(),h=L(),t=F({rect:null,width:0,height:0,offset:0,active:0,swiping:!1});let S=!1;const r=re(),{children:w,linkChildren:s}=ve(te),i=d(()=>w.length),o=d(()=>t[a.vertical?"height":"width"]),v=d(()=>a.vertical?r.deltaY.value:r.deltaX.value),b=d(()=>t.rect?(a.vertical?t.rect.height:t.rect.width)-o.value*i.value:0),M=d(()=>o.value?Math.ceil(Math.abs(b.value)/o.value):i.value),_=d(()=>i.value*o.value),p=d(()=>(t.active+i.value)%i.value),R=d(()=>{const e=a.vertical?"vertical":"horizontal";return r.direction.value===e}),ae=d(()=>{const e={transitionDuration:`${t.swiping?0:a.duration}ms`,transform:`translate${a.vertical?"Y":"X"}(${t.offset}px)`};if(o.value){const l=a.vertical?"height":"width",n=a.vertical?"width":"height";e[l]=`${_.value}px`,e[n]=a[n]?`${a[n]}px`:""}return e}),ie=e=>{const{active:l}=t;return e?a.loop?B(l+e,-1,i.value):B(l+e,0,M.value):l},Y=(e,l=0)=>{let n=e*o.value;a.loop||(n=Math.min(n,-b.value));let f=l-n;return a.loop||(f=B(f,b.value,0)),f},m=({pace:e=0,offset:l=0,emitChange:n})=>{if(i.value<=1)return;const{active:f}=t,c=ie(e),C=Y(c,l);if(a.loop){if(w[0]&&C!==b.value){const O=C0;w[i.value-1].setOffset(O?-_.value:0)}}t.active=c,t.offset=C,n&&c!==f&&y("change",p.value)},$=()=>{t.swiping=!0,t.active<=-1?m({pace:i.value}):t.active>=i.value&&m({pace:-i.value})},ne=()=>{$(),r.reset(),E(()=>{t.swiping=!1,m({pace:-1,emitChange:!0})})},X=()=>{$(),r.reset(),E(()=>{t.swiping=!1,m({pace:1,emitChange:!0})})};let W;const T=()=>clearTimeout(W),P=()=>{T(),+a.autoplay>0&&i.value>1&&(W=setTimeout(()=>{X(),P()},+a.autoplay))},x=(e=+a.initialSwipe)=>{if(!u.value)return;const l=()=>{var n,f;if(!U(u)){const c={width:u.value.offsetWidth,height:u.value.offsetHeight};t.rect=c,t.width=+((n=a.width)!=null?n:c.width),t.height=+((f=a.height)!=null?f:c.height)}i.value&&(e=Math.min(i.value-1,e),e===-1&&(e=i.value-1)),t.active=e,t.swiping=!0,t.offset=Y(e),w.forEach(c=>{c.setOffset(0)}),P()};U(u)?Q().then(l):l()},H=()=>x(t.active);let N;const le=e=>{!a.touchable||e.touches.length>1||(r.start(e),S=!1,N=Date.now(),T(),$())},oe=e=>{a.touchable&&t.swiping&&(r.move(e),R.value&&(!a.loop&&(t.active===0&&v.value>0||t.active===i.value-1&&v.value<0)||(Se(e,a.stopPropagation),m({offset:v.value}),S||(y("dragStart",{index:p.value}),S=!0))))},V=()=>{if(!a.touchable||!t.swiping)return;const e=Date.now()-N,l=v.value/e;if((Math.abs(l)>.25||Math.abs(v.value)>o.value/2)&&R.value){const f=a.vertical?r.offsetY.value:r.offsetX.value;let c=0;a.loop?c=f>0?v.value>0?-1:1:0:c=-Math[v.value>0?"ceil":"floor"](v.value/o.value),m({pace:c,emitChange:!0})}else v.value&&m({pace:0});S=!1,t.swiping=!1,y("dragEnd",{index:p.value}),P()},se=(e,l={})=>{$(),r.reset(),E(()=>{let n;a.loop&&e===i.value?n=t.active===0?0:e:n=e%i.value,l.immediate?E(()=>{t.swiping=!1}):t.swiping=!1,m({pace:n-t.active,emitChange:!0})})},ce=(e,l)=>{const n=l===p.value,f=n?{backgroundColor:a.indicatorColor}:void 0;return I("i",{style:f,class:k("indicator",{active:n})},null)},ue=()=>{if(g.indicator)return g.indicator({active:p.value,total:i.value});if(a.showIndicators&&i.value>1)return I("div",{class:k("indicators",{vertical:a.vertical})},[Array(i.value).fill("").map(ce)])};return G({prev:ne,next:X,state:t,resize:H,swipeTo:se}),s({size:o,props:a,count:i,activeIndicator:p}),z(()=>a.initialSwipe,e=>x(+e)),z(i,()=>x(t.active)),z(()=>a.autoplay,P),z([fe,de,()=>a.width,()=>a.height],H),z(he(),e=>{e==="visible"?P():T()}),J(x),ge(()=>x(t.active)),we(()=>x(t.active)),me(T),be(T),ye("touchmove",oe,{target:h}),()=>{var e;return I("div",{ref:u,class:k()},[I("div",{ref:h,style:ae.value,class:k("track",{vertical:a.vertical}),onTouchstartPassive:le,onTouchend:V,onTouchcancel:V},[(e=g.default)==null?void 0:e.call(g)]),ue()])}}});const $e=Z(Te),[Pe,Ce]=j("swipe-item");var ze=q({name:Pe,setup(a,{slots:y}){let g;const u=F({offset:0,inited:!1,mounted:!1}),{parent:h,index:t}=pe(te);if(!h){console.error("[Vant] must be a child component of .");return}const S=d(()=>{const s={},{vertical:i}=h.props;return h.size.value&&(s[i?"height":"width"]=`${h.size.value}px`),u.offset&&(s.transform=`translate${i?"Y":"X"}(${u.offset}px)`),s}),r=d(()=>{const{loop:s,lazyRender:i}=h.props;if(!i||g)return!0;if(!u.mounted)return!1;const o=h.activeIndicator.value,v=h.count.value-1,b=o===0&&s?v:o-1,M=o===v&&s?0:o+1;return g=t.value===o||t.value===b||t.value===M,g}),w=s=>{u.offset=s};return J(()=>{Q(()=>{u.mounted=!0})}),G({setOffset:w}),()=>{var s;return I("div",{class:Ce(),style:S.value},[r.value?(s=y.default)==null?void 0:s.call(y):null])}}});const Ae=Z(ze);export{$e as S,Ae as a};