import{d as w,h as x,i as D,o as C,l as O,u as c,b as X,r as P,s as _}from"./Dih1Xbo1.js";const G=w({__name:"LoadingProgress",props:{loading:{type:Boolean},throttle:{default:20},duration:{default:200},height:{default:3},color:{type:[String,Boolean],default:"repeating-linear-gradient(to right,#00dc82 0%,#34cdfe 50%,#0047e1 100%)"},estimatedProgress:{}},setup(L){const s=L;function b(e,a){const n=a/e*100;return 2/Math.PI*100*Math.atan(n/50)}function k(){const e=s.duration,a=s.throttle,n=500,$=400,z=s.estimatedProgress||b,o=P(0),r=P(!1);let i=!1,l,f,m,g;const A=()=>h(0);function h(t=0){if(t>=100)return p();u(),o.value=t<0?0:t,a?f=setTimeout(()=>{r.value=!0,v()},a):(r.value=!0,v())}function E(){m=setTimeout(()=>{r.value=!1,g=setTimeout(()=>{o.value=0},$)},n)}function p(t={}){o.value=100,i=!0,u(),F(),t.force?(o.value=0,r.value=!1):E()}function F(){clearTimeout(m),clearTimeout(g)}function u(){clearTimeout(f),cancelAnimationFrame(l)}function v(){i=!1;let t;function T(y){if(i)return;t??=y;const q=y-t;o.value=Math.max(0,Math.min(100,z(e,q))),l=requestAnimationFrame(T)}l=requestAnimationFrame(T)}return{progress:_(()=>o.value),isLoading:_(()=>r.value),start:A,set:h,finish:p,clear:u}}const{clear:B,finish:I,start:M,isLoading:S,progress:d}=k();return x(()=>s.loading,e=>{e?M():(I(),B())},{immediate:!0}),(e,a)=>(C(),D("div",{class:"loading-progress-indicator",style:O({position:"absolute",top:"0",right:"0",left:"0",pointerEvents:"none",width:"auto",height:`${e.height}px`,opacity:c(S)?"1":"0",background:e.color||void 0,backgroundSize:`${100/c(d)*100}% auto`,transform:`scaleX(${c(d)}%)`,transformOrigin:"left",transition:"transform 0.1s, height 0.4s, opacity 0.4s",zIndex:"999999"})},[X(e.$slots,"default")],4))}});export{G as _};
