import { stringifyNumber as p } from "./accelbyte-widgets756.mjs";
function g(e, t) {
  const n = e[0], a = n === "-" || n === "+" ? e.substring(1) : e, r = (i) => t ? BigInt(i) : Number(i), s = a.replace(/_/g, "").split(":").reduce((i, o) => i * r(60) + r(o), r(0));
  return n === "-" ? r(-1) * s : s;
}
function u(e) {
  let { value: t } = e, n = (i) => i;
  if (typeof t == "bigint")
    n = (i) => BigInt(i);
  else if (isNaN(t) || !isFinite(t))
    return p(e);
  let a = "";
  t < 0 && (a = "-", t *= n(-1));
  const r = n(60), s = [t % r];
  return t < 60 ? s.unshift(0) : (t = (t - s[0]) / r, s.unshift(t % r), t >= 60 && (t = (t - s[0]) / r, s.unshift(t))), a + s.map((i) => String(i).padStart(2, "0")).join(":").replace(/000000\d*$/, "");
}
const b = {
  identify: (e) => typeof e == "bigint" || Number.isInteger(e),
  default: !0,
  tag: "tag:yaml.org,2002:int",
  format: "TIME",
  test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
  resolve: (e, t, { intAsBigInt: n }) => g(e, n),
  stringify: u
}, h = {
  identify: (e) => typeof e == "number",
  default: !0,
  tag: "tag:yaml.org,2002:float",
  format: "TIME",
  test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
  resolve: (e) => g(e, !1),
  stringify: u
}, y = {
  identify: (e) => e instanceof Date,
  default: !0,
  tag: "tag:yaml.org,2002:timestamp",
  test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),
  resolve(e) {
    const t = e.match(y.test);
    if (!t)
      throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
    const [, n, a, r, s, i, o] = t.map(Number), c = t[7] ? Number((t[7] + "00").substr(1, 3)) : 0;
    let l = Date.UTC(n, a - 1, r, s || 0, i || 0, o || 0, c);
    const f = t[8];
    if (f && f !== "Z") {
      let m = g(f, !1);
      Math.abs(m) < 30 && (m *= 60), l -= 6e4 * m;
    }
    return new Date(l);
  },
  stringify: ({ value: e }) => e.toISOString().replace(/((T00:00)?:00)?\.000Z$/, "")
};
export {
  h as floatTime,
  b as intTime,
  y as timestamp
};
