import{_ as u,o as h,c,t as d}from"./index.df7b46f6.js";let n=0;const o="webkit moz ms o".split(" ");let a,s;const p=typeof window>"u";if(p)a=function(){},s=function(){};else{a=window.requestAnimationFrame,s=window.cancelAnimationFrame;let i;for(let t=0;t<o.length&&!(a&&s);t++)i=o[t],a=a||window[i+"RequestAnimationFrame"],s=s||window[i+"CancelAnimationFrame"]||window[i+"CancelRequestAnimationFrame"];(!a||!s)&&(a=function(t){const e=new Date().getTime(),l=Math.max(0,16-(e-n)),r=window.setTimeout(()=>{t(e+l)},l);return n=e+l,r},s=function(t){window.clearTimeout(t)})}const f={props:{startVal:{type:Number,required:!1,default:0},endVal:{type:Number,required:!1,default:2017},duration:{type:Number,required:!1,default:3e3},autoplay:{type:Boolean,required:!1,default:!0},decimals:{type:Number,required:!1,default:0,validator(i){return i>=0}},decimal:{type:String,required:!1,default:"."},separator:{type:String,required:!1,default:","},prefix:{type:String,required:!1,default:""},suffix:{type:String,required:!1,default:""},useEasing:{type:Boolean,required:!1,default:!0},easingFn:{type:Function,default(i,t,e,l){return e*(-Math.pow(2,-10*i/l)+1)*1024/1023+t}}},data(){return{localStartVal:this.startVal,displayValue:this.formatNumber(this.startVal),printVal:null,paused:!1,localDuration:this.duration,startTime:null,timestamp:null,remaining:null,rAF:null}},computed:{countDown(){return this.startVal>this.endVal}},watch:{startVal(){this.autoplay&&this.start()},endVal(){this.autoplay&&this.start()}},mounted(){this.autoplay&&this.start(),this.$emit("mountedCallback")},methods:{start(){this.localStartVal=this.startVal,this.startTime=null,this.localDuration=this.duration,this.paused=!1,this.rAF=a(this.count)},pauseResume(){this.paused?(this.resume(),this.paused=!1):(this.pause(),this.paused=!0)},pause(){s(this.rAF)},resume(){this.startTime=null,this.localDuration=+this.remaining,this.localStartVal=+this.printVal,a(this.count)},reset(){this.startTime=null,s(this.rAF),this.displayValue=this.formatNumber(this.startVal)},count(i){this.startTime||(this.startTime=i),this.timestamp=i;const t=i-this.startTime;this.remaining=this.localDuration-t,this.useEasing?this.countDown?this.printVal=this.localStartVal-this.easingFn(t,0,this.localStartVal-this.endVal,this.localDuration):this.printVal=this.easingFn(t,this.localStartVal,this.endVal-this.localStartVal,this.localDuration):this.countDown?this.printVal=this.localStartVal-(this.localStartVal-this.endVal)*(t/this.localDuration):this.printVal=this.localStartVal+(this.endVal-this.localStartVal)*(t/this.localDuration),this.countDown?this.printVal=this.printVal<this.endVal?this.endVal:this.printVal:this.printVal=this.printVal>this.endVal?this.endVal:this.printVal,this.displayValue=this.formatNumber(this.printVal),t<this.localDuration?this.rAF=a(this.count):this.$emit("callback")},isNumber(i){return!isNaN(parseFloat(i))},formatNumber(i){i=i.toFixed(this.decimals),i+="";const t=i.split(".");let e=t[0];const l=t.length>1?this.decimal+t[1]:"",r=/(\d+)(\d{3})/;if(this.separator&&!this.isNumber(this.separator))for(;r.test(e);)e=e.replace(r,"$1"+this.separator+"$2");return this.prefix+e+l+this.suffix}},destroyed(){s(this.rAF)}};function m(i,t,e,l,r,V){return h(),c("span",null,d(r.displayValue),1)}const y=u(f,[["render",m]]);export{y as C};
