"use strict";var _times=require("../../../utils/times"),_utils=require("../../../utils/utils");Component({properties:{sendTime:{type:Number,value:null},deadLine:{type:Number,value:null},deadLineSecond:{type:Number,value:null},timeOverText:{type:String,value:""},type:{type:String,value:null},isDownWarn:{type:Boolean,value:!1},useDarkTheme:{type:Boolean,value:!1},awardThemeUrl:{type:String,value:""},forceZero:{type:Boolean,value:!1}},data:{countdownText:""},lifetimes:{attached:function(){},detached:function(){clearInterval(this.timerRef)}},observers:{sendTime:function(){this.syncCountdown()},forceZero:function(){this.syncCountdown()}},methods:{syncCountdown:function(){if(this.timerRef&&clearInterval(this.timerRef),this.data.forceZero)(0,_utils.setDataIfChanged)(this,{countdownText:"00:00"});else if(this.data.sendTime){var e=this.getCountDownText({sendTime:this.data.sendTime,deadLine:this.data.deadLine,deadLineSecond:this.data.deadLineSecond});(0,_utils.setDataIfChanged)(this,{countdownText:e}),"00:00"!==e?this.timerRef=setInterval(this.loop.bind(this),1e3):this.onCountDown()}},loop:function(){if(this.data.forceZero)return(0,_utils.setDataIfChanged)(this,{countdownText:"00:00"}),void clearInterval(this.timerRef);var e=this.getCountDownText({sendTime:this.data.sendTime,deadLine:this.data.deadLine,deadLineSecond:this.data.deadLineSecond});(0,_utils.setDataIfChanged)(this,{countdownText:e});var t=e.split(":");"00"===t[0]&&10===Number(t[1])&&this.onCountDownWarn(),"00:00"===e&&(this.onCountDown(),clearInterval(this.timerRef))},getCountDownText:function(e){var t=e.sendTime,n=e.deadLine,i=e.deadLineSecond;return(0,_times.getCountDownV2)(t,n,i).join(":")},onCountDown:function(){this.triggerEvent("onCountDown")},onCountDownWarn:function(){this.triggerEvent("onCountDownWarn")}}});