"use strict";const convertTime=(e,t)=>{let a=timeOffset(e);return{week:a.weeks,day:t.enableWeek?a.days:a.totalDays,hour:t.enableDay?a.hours:a.totalHours,minute:t.enableHour||t.enableDay||t.enableWeek?a.minutes:a.totalMinutes,second:t.enableMinute||t.enableHour||t.enableDay||t.enableWeek?a.seconds:a.totalSeconds}},timeOffset=e=>({seconds:e%60,minutes:Math.floor(e/60)%60,hours:Math.floor(e/60/60)%24,days:Math.floor(e/60/60/24)%7,weeks:Math.floor(e/60/60/24/7),months:Math.floor(e/60/60/24/30.4368),totalDays:Math.floor(e/60/60/24),totalHours:Math.floor(e/60/60),totalMinutes:Math.floor(e/60),totalSeconds:e}),formatTime=e=>Number.isNaN(e)||0===e?"00":e<10?`0${e}`:e,calculateTime=e=>{let t=new Date().getTime();e||(e=getEndTime(0,3,0));let a=Math.ceil((e-t)/1e3);return a>0?a:0},getEndTime=(e,t,a)=>{let r=new Date,n=new Date;return r.setDate(n.getDate()+e),r.setHours(n.getHours()+t),r.setMinutes(n.getMinutes()+a),r.setSeconds(n.getSeconds()),r.getTime()},daily=(e,t,a)=>{let r=new Date,n=to24HrTime(`${e}:${t} ${a}`);e=n.hours,t=n.mins;let s=new Date(r.getFullYear(),r.getMonth(),r.getDate(),e,t).getTime(),o=s-r.getTime();return o<0&&(o+=864e5),Math.ceil(o/1e3)},standard=(e,t)=>calculateTime(getStandardEndtime(e,t)),getStandardEndtime=(e,t)=>{let a=0,r=new Date(e);if(void 0!=t&&""!=t&&((a=parseInt(t)?parseInt(t):parseInt(t.slice(3)))||0===a)){let e=new Date().getTimezoneOffset();r=new Date(r.getTime()-6e4*e-36e5*a)}return r.getTime()},evergreen=e=>{let{days:t,hours:a,mins:r,seconds:n=0}=e;return(t??0)*86400+(a??0)*3600+(r??0)*60+(n??0)},refreshAfterFinish=(e,t)=>{let a=new Date().getTime(),r=(86400*t.days+3600*t.hours+60*t.mins)*1e3,n=(a-e)%r;return Math.ceil((r-n)/1e3)},to24HrTime=e=>{let[t,a,r]=e.toLowerCase().match(/\d+|[a-z]+/g)||[],n=`${Number(t)%12+("am"==r?0:12)}:${a}`.split(":");return{hours:parseInt(n[0]?n[0]:"0"),mins:parseInt(n[1]?n[1]:"0")}};exports.calculateTime=calculateTime,exports.convertTime=convertTime,exports.daily=daily,exports.evergreen=evergreen,exports.formatTime=formatTime,exports.getEndTime=getEndTime,exports.getStandardEndtime=getStandardEndtime,exports.refreshAfterFinish=refreshAfterFinish,exports.standard=standard;
