import{isNumericInvariant as t}from"./_number.js";export class Time{_isValid;_time;get isValid(){return this._isValid}constructor(i){if("string"==typeof i){const e=i.split(":");8===i.length&&3===e.length&&e.every((i=>2===i.length&&t(i)))?(this._time=i,this._isValid=!0):(this._time="Invalid time",this._isValid=!1)}else isNaN(i.getTime())?(this._time="Invalid time",this._isValid=!1):(this._time=`${i.getHours().toString().padStart(2,"0")}:${i.getMinutes().toString().padStart(2,"0")}:${i.getSeconds().toString().padStart(2,"0")}`,this._isValid=!0)}toString(){return this._time}toDate(){if(!this.isValid)return new Date(NaN);const t=new Date,i=this._time.split(":");return t.setHours(parseInt(i[0])),t.setMinutes(parseInt(i[1])),t.setSeconds(parseInt(i[2])),t.setMilliseconds(0),t}}