document.addEventListener("alpine:init",()=>{Alpine.data("dataResult",()=>({isLoad:!0,search:"",data:[],init(){this.getData(),this.$watch("sPrediksi",t=>{this.isLoad=!0,this.getData()})},getData(){var a;let t=(a=this.sPrediksi)!=null?a:"";this.resetCountDown(),axios.get("/client/blog/result/json?p="+t).then(s=>{let n=s.data.map((e,h)=>{let o=moment().unix(),i=moment(e.jam_undi,"HH:mm:ss").unix(),r=moment(e.jam_undi,"HH:mm:ss").add(30,"minutes").unix();e.live=o>=i&&o<=r;let d=moment(e.result_one.created_at).format("YYYYMMDD"),m=moment().format("YYYYMMDD");return d!=m&&i>o?e.nextDraw=moment(e.jam_undi,"HH:mm:ss").format("YYYY-MM-DD HH:mm:ss"):e.nextDraw=moment(e.jam_undi,"HH:mm:ss").add(1,"day").format("YYYY-MM-DD HH:mm:ss"),e.timer={hours:0,minutes:0,seconds:0},$this=this,e.countdown=e.live?null:countdown(new Date(e.nextDraw),u=>$this.updateTimer(u,h),countdown.HOURS|countdown.MINUTES|countdown.SECONDS),e});this.isLoad=!1,this.data=n,scrollInMenuHome(),setTimeout(()=>{this.highLight()})}).catch(s=>{this.isLoad=!1,Toast(s.message)})},resetCountDown(){this.data.forEach((t,a)=>{t.countdown&&window.clearInterval(t.countdown)})},stopCountDown(t){setTimeout(()=>{this.data[t].live=!0,window.clearInterval(this.data[t].countdown)})},updateTimer(t,a){const{hours:s,minutes:n,seconds:e}=t;setTimeout(()=>{this.data[a]&&(this.data[a].timer={hours:s,minutes:n,seconds:e})}),s==0&&n==0&&e==0&&this.stopCountDown(a)},addZero(t){return t.toString().length==1?"0"+t:t},onSearch(){this.isLoad=!0,this.data.forEach(t=>{t.countdown&&window.clearInterval(t.countdown)}),this.getData()},highLight(){const t=this.search,a=t.charAt(0).toUpperCase()+t.slice(1),s=t.toUpperCase();let n=document.querySelectorAll(".hlsText");[...n].forEach(e=>highLightSearch(t,e)),[...n].forEach(e=>highLightSearch(a,e)),[...n].forEach(e=>highLightSearch(s,e))}}))});