"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");require("../config-provider/index.js");const A=require("../config-provider/hooks/use-token.js");require("../utils/index.js");const F=require("./style/index.js"),B=require("../config-provider/hooks/use-namespace.js"),h=require("../utils/is.js"),D=["aria-valuenow"],C=.05,I=e.defineComponent({__name:"index",props:{defaultProgress:{default:0},barSize:{default:2},status:{default:"default"},position:{default:"top"},stopProgress:{default:90},manul:{type:Boolean,default:!1}},setup(S,{expose:_}){const t=S,{token:x}=A.useToken(),l=e.computed(()=>x.value?.components?.LoadingBar?.loadingBarAnimateDuration??250),o=e.ref(!1),{b:f,m:z,e:q}=B.useNamespace("loading-bar"),w=F.default("loading-bar"),n=e.ref(t.position),s=e.ref(t.defaultProgress),u=e.ref(t.status),i=e.ref(t.stopProgress),c=e.ref(t.barSize),d=e.ref(!1);e.watch(()=>t.status,a=>{u.value=a}),e.watch(()=>t.stopProgress,a=>{i.value=a}),e.watch(()=>t.position,a=>n.value=a),e.watch(()=>t.barSize,a=>c.value=a);const P=e.computed(()=>[f(),z(u.value),w.value]),T=e.computed(()=>({[n.value]:0,height:`${c.value}px`,...d.value?{position:"fixed",zIndex:99}:{}})),k=e.computed(()=>({transform:`translateX(${(s.value-100)/2}%) scaleX(${s.value/100})`}));let r;const v=()=>{const a=i.value-s.value;if(a<=0){r&&cancelAnimationFrame(r);return}s.value+=a*C,r=requestAnimationFrame(v)};let p;const y=a=>{d.value=a?._globalMark??!1,a?.position&&(n.value=a?.position),a?.barSize&&(c.value=a.barSize),r&&cancelAnimationFrame(r),clearTimeout(p),o.value=!0,setTimeout(()=>{const{progress:m,stopProgress:g,status:b}=a||{};h.isDef(m)&&(s.value=m),h.isDef(g)&&(i.value=g),b&&(u.value=b),p=setTimeout(()=>{o.value=!0,r=requestAnimationFrame(v)},l.value)})};return e.onMounted(()=>{t.manul||(o.value=!0,requestAnimationFrame(v))}),e.onBeforeUnmount(()=>{o.value=!1,r&&cancelAnimationFrame(r)}),e.watch(()=>s.value,a=>{a===100&&setTimeout(()=>{o.value=!1,setTimeout(()=>{s.value=0,u.value="default"},l.value)},l.value)}),_({start:y,done(a){s.value=100,a&&(u.value=a)}}),(a,m)=>(e.openBlock(),e.createBlock(e.Transition,{name:e.unref(f)("fade")},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(P.value),style:e.normalizeStyle(T.value)},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(q)("bar")),style:e.normalizeStyle(k.value),role:"progressbar","aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":s.value},null,14,D)],6),[[e.vShow,o.value]])]),_:1},8,["name"]))}});exports.default=I;
