import{j as I,ak as m,t as L,d as H,i as V,az as M,O as k,af as N,w as p,ag as U,g as l,$ as q,y as A,aC as B,ah as W,D as C,F as Y,h as j}from"./index-8911ca98.js";import{I as T}from"./index-4522bae7.js";const[z,f,G]=I("pull-refresh"),R=50,O=["pulling","loosing","success"],X={disabled:Boolean,modelValue:Boolean,headHeight:m(R),successText:String,pullingText:String,loosingText:String,loadingText:String,pullDistance:L,successDuration:m(500),animationDuration:m(300)};var J=H({name:z,props:X,emits:["change","refresh","update:modelValue"],setup(a,{emit:i,slots:u}){let n;const o=V(),v=V(),y=M(o),t=k({status:"normal",distance:0,duration:0}),r=N(),P=()=>{if(a.headHeight!==R)return{height:`${a.headHeight}px`}},g=()=>t.status!=="loading"&&t.status!=="success"&&!a.disabled,E=e=>{const s=+(a.pullDistance||a.headHeight);return e>s&&(e<s*2?e=s+(e-s)/2:e=s*1.5+(e-s*2)/4),Math.round(e)},c=(e,s)=>{const d=+(a.pullDistance||a.headHeight);t.distance=e,s?t.status="loading":e===0?t.status="normal":e<d?t.status="pulling":t.status="loosing",i("change",{status:t.status,distance:e})},D=()=>{const{status:e}=t;return e==="normal"?"":a[`${e}Text`]||G(e)},$=()=>{const{status:e,distance:s}=t;if(u[e])return u[e]({distance:s});const d=[];return O.includes(e)&&d.push(l("div",{class:f("text")},[D()])),e==="loading"&&d.push(l(q,{class:f("loading")},{default:D})),d},w=()=>{t.status="success",setTimeout(()=>{c(0)},+a.successDuration)},x=e=>{n=B(y.value)===0,n&&(t.duration=0,r.start(e))},b=e=>{g()&&x(e)},F=e=>{if(g()){n||x(e);const{deltaY:s}=r;r.move(e),n&&s.value>=0&&r.isVertical()&&(W(e),c(E(s.value)))}},_=()=>{n&&r.deltaY.value&&g()&&(t.duration=+a.animationDuration,t.status==="loosing"?(c(+a.headHeight,!0),i("update:modelValue",!0),A(()=>i("refresh"))):c(0))};return p(()=>a.modelValue,e=>{t.duration=+a.animationDuration,e?c(+a.headHeight,!0):u.success||a.successText?w():c(0,!1)}),U("touchmove",F,{target:v}),()=>{var e;const s={transitionDuration:`${t.duration}ms`,transform:t.distance?`translate3d(0,${t.distance}px, 0)`:""};return l("div",{ref:o,class:f()},[l("div",{ref:v,class:f("track"),style:s,onTouchstartPassive:b,onTouchend:_,onTouchcancel:_},[l("div",{class:f("head"),style:P()},[$()]),(e=u.default)==null?void 0:e.call(u)])])}}});const K=C(J),Q="_animateWrap_1kuq9_1",Z="_loading_1kuq9_5",ee="_pullRefresh_1kuq9_13",h={animateWrap:Q,loading:Z,pullRefresh:ee};const S=""+new URL("loading-9729222e.gif",import.meta.url).href,se=H({name:"s-full-refresh",props:{title:String,modelValue:{type:Boolean,default:!1}},emits:["refresh","update:modelValue"],setup(a,{emit:i,slots:u}){const n=k({fullState:!1});return p(()=>a.modelValue,o=>{n.fullState=o}),p(()=>n.fullState,o=>{i("update:modelValue",o)}),()=>l(K,{modelValue:n.fullState,"onUpdate:modelValue":o=>n.fullState=o,onRefresh:()=>i("refresh"),loadingText:" ",class:h.pullRefresh},{loading:()=>l("div",null,[l(T,{src:S,class:h.loading},null)]),pulling:()=>l("div",null,[l(T,{src:S,class:h.loading},null)]),loosing:()=>l("div",null,[l(T,{src:S,class:h.loading},null)]),default:()=>l(Y,null,[j(" "),u.default&&u.default()])})}});export{se as M};
