import{t as b,z as g,E as F,d as H,R as _,ao as $,r as R,ap as w,Z as p,a0 as B,c as l,L as O,a4 as U,_ as q,aq as I,x as M,V as T,A as S,F as Y,q as z}from"./index.27735e87.js";const[C,f,G]=b("pull-refresh"),P=50,J=["pulling","loosing","success"],X={disabled:Boolean,modelValue:Boolean,headHeight:g(P),successText:String,pullingText:String,loosingText:String,loadingText:String,pullDistance:F,successDuration:g(500),animationDuration:g(300)};var Z=H({name:C,props:X,emits:["change","refresh","update:modelValue"],setup(a,{emit:i,slots:u}){let n;const o=_(),v=_(),E=$(o),t=R({status:"normal",distance:0,duration:0}),c=w(),k=()=>{if(a.headHeight!==P)return{height:`${a.headHeight}px`}},m=()=>t.status!=="loading"&&t.status!=="success"&&!a.disabled,y=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)},r=(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)},W=()=>{const{status:e,distance:s}=t;if(u[e])return u[e]({distance:s});const d=[];return J.includes(e)&&d.push(l("div",{class:f("text")},[D()])),e==="loading"&&d.push(l(O,{class:f("loading")},{default:D})),d},A=()=>{t.status="success",setTimeout(()=>{r(0)},+a.successDuration)},x=e=>{n=I(E.value)===0,n&&(t.duration=0,c.start(e))},L=e=>{m()&&x(e)},N=e=>{if(m()){n||x(e);const{deltaY:s}=c;c.move(e),n&&s.value>=0&&c.isVertical()&&(U(e),r(y(s.value)))}},V=()=>{n&&c.deltaY.value&&m()&&(t.duration=+a.animationDuration,t.status==="loosing"?(r(+a.headHeight,!0),i("update:modelValue",!0),q(()=>i("refresh"))):r(0))};return p(()=>a.modelValue,e=>{t.duration=+a.animationDuration,e?r(+a.headHeight,!0):u.success||a.successText?A():r(0,!1)}),B("touchmove",N,{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:L,onTouchend:V,onTouchcancel:V},[l("div",{class:f("head"),style:k()},[W()]),(e=u.default)==null?void 0:e.call(u)])])}}});const j=M(Z),K="_animateWrap_127dt_1",Q="_pullRefresh_127dt_5";var h={animateWrap:K,pullRefresh:Q},te=H({name:"o-full-refresh",props:{title:String,modelValue:{type:Boolean,default:!1}},emits:["refresh","update:modelValue"],setup(a,{emit:i,slots:u}){const n=R({fullState:!1});return p(()=>a.modelValue,o=>{n.fullState=o}),p(()=>n.fullState,o=>{i("update:modelValue",o)}),()=>l(j,{modelValue:n.fullState,"onUpdate:modelValue":o=>n.fullState=o,onRefresh:()=>i("refresh"),loadingText:" ",class:h.pullRefresh},{loading:()=>l("div",null,[l(T,{class:h.animateWrap,animationData:S},null)]),pulling:()=>l("div",null,[l(T,{class:h.animateWrap,animationData:S},null)]),loosing:()=>l("div",null,[l(T,{class:h.animateWrap,animationData:S},null)]),default:()=>l(Y,null,[z(" "),u.default&&u.default()])})}});export{te as O};
