import { t as l, c as v, g as A, e as C, a as $, m as P, b as x, f as R, d as X, h as B } from "./index-DFOb_6HB.js";
function M(t, e) {
  const r = l(t), c = l(e), n = r.getTime() - c.getTime();
  return n < 0 ? -1 : n > 0 ? 1 : n;
}
function V(t) {
  return v(t, Date.now());
}
function Y(t, e) {
  const r = l(t), c = l(e), n = r.getFullYear() - c.getFullYear(), i = r.getMonth() - c.getMonth();
  return n * 12 + i;
}
function W(t) {
  return (e) => {
    const c = (t ? Math[t] : Math.trunc)(e);
    return c === 0 ? 0 : c;
  };
}
function k(t, e) {
  return +l(t) - +l(e);
}
function E(t) {
  const e = l(t);
  return e.setHours(23, 59, 59, 999), e;
}
function j(t) {
  const e = l(t), r = e.getMonth();
  return e.setFullYear(e.getFullYear(), r + 1, 0), e.setHours(23, 59, 59, 999), e;
}
function H(t) {
  const e = l(t);
  return +E(e) == +j(e);
}
function K(t, e) {
  const r = l(t), c = l(e), n = M(r, c), i = Math.abs(
    Y(r, c)
  );
  let a;
  if (i < 1)
    a = 0;
  else {
    r.getMonth() === 1 && r.getDate() > 27 && r.setDate(30), r.setMonth(r.getMonth() - n * i);
    let u = M(r, c) === -n;
    H(l(t)) && i === 1 && M(t, c) === 1 && (u = !1), a = n * (i - Number(u));
  }
  return a === 0 ? 0 : a;
}
function q(t, e, r) {
  const c = k(t, e) / 1e3;
  return W(r == null ? void 0 : r.roundingMethod)(c);
}
function J(t, e, r) {
  const c = A(), n = (r == null ? void 0 : r.locale) ?? c.locale ?? C, i = 2520, a = M(t, e);
  if (isNaN(a))
    throw new RangeError("Invalid time value");
  const u = Object.assign({}, r, {
    addSuffix: r == null ? void 0 : r.addSuffix,
    comparison: a
  });
  let f, d;
  a > 0 ? (f = l(e), d = l(t)) : (f = l(t), d = l(e));
  const m = q(d, f), w = ($(d) - $(f)) / 1e3, s = Math.round((m - w) / 60);
  let h;
  if (s < 2)
    return r != null && r.includeSeconds ? m < 5 ? n.formatDistance("lessThanXSeconds", 5, u) : m < 10 ? n.formatDistance("lessThanXSeconds", 10, u) : m < 20 ? n.formatDistance("lessThanXSeconds", 20, u) : m < 40 ? n.formatDistance("halfAMinute", 0, u) : m < 60 ? n.formatDistance("lessThanXMinutes", 1, u) : n.formatDistance("xMinutes", 1, u) : s === 0 ? n.formatDistance("lessThanXMinutes", 1, u) : n.formatDistance("xMinutes", s, u);
  if (s < 45)
    return n.formatDistance("xMinutes", s, u);
  if (s < 90)
    return n.formatDistance("aboutXHours", 1, u);
  if (s < P) {
    const g = Math.round(s / 60);
    return n.formatDistance("aboutXHours", g, u);
  } else {
    if (s < i)
      return n.formatDistance("xDays", 1, u);
    if (s < x) {
      const g = Math.round(s / P);
      return n.formatDistance("xDays", g, u);
    } else if (s < x * 2)
      return h = Math.round(s / x), n.formatDistance("aboutXMonths", h, u);
  }
  if (h = K(d, f), h < 12) {
    const g = Math.round(s / x);
    return n.formatDistance("xMonths", g, u);
  } else {
    const g = h % 12, y = Math.trunc(h / 12);
    return g < 3 ? n.formatDistance("aboutXYears", y, u) : g < 9 ? n.formatDistance("overXYears", y, u) : n.formatDistance("almostXYears", y + 1, u);
  }
}
function Q(t, e) {
  return J(t, V(t), e);
}
function S(t) {
  if (!t) return !1;
  const e = t.toLowerCase().replace("_", "-");
  return e === "en-in" || e.startsWith("en-in-");
}
function T(t, e) {
  const r = Math.abs(t);
  return r >= 1e12 ? { divisor: 1e12, suffix: "T" } : r >= 1e9 ? { divisor: 1e9, suffix: "B" } : S(e) && r >= 1e7 ? { divisor: 1e7, suffix: "Cr" } : r >= 1e6 ? { divisor: 1e6, suffix: "M" } : S(e) && r >= 1e5 ? { divisor: 1e5, suffix: "L" } : r >= 1e3 ? { divisor: 1e3, suffix: "K" } : { divisor: 1, suffix: "" };
}
function N(t, e) {
  try {
    const r = D(e);
    return T(t, r);
  } catch {
    return T(t, "en-US");
  }
}
function F(t) {
  try {
    return new Intl.NumberFormat(t), !0;
  } catch {
    return !1;
  }
}
function D(t) {
  return t && F(t) ? t : "en-US";
}
function U(t, e) {
  if (t == null || isNaN(t))
    return "";
  const r = D(e == null ? void 0 : e.locale);
  let c = t;
  if (e != null && e.multiplyBy && (c *= e.multiplyBy), e != null && e.useSuffix) {
    const { divisor: i, suffix: a } = N(c, r);
    c = c / i;
    const u = new Intl.NumberFormat(r, {
      minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
      maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
      useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
    }).format(c);
    return `${(e == null ? void 0 : e.prefix) ?? ""}${u}${a}${(e == null ? void 0 : e.suffix) ?? ""}`;
  }
  const n = new Intl.NumberFormat(r, {
    minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
    maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
    useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
  }).format(c);
  if (e != null && e.negativeInParentheses && c < 0) {
    const i = n.replace("-", "");
    return `(${(e == null ? void 0 : e.prefix) ?? ""}${i}${(e == null ? void 0 : e.suffix) ?? ""})`;
  }
  return `${(e == null ? void 0 : e.prefix) ?? ""}${n}${(e == null ? void 0 : e.suffix) ?? ""}`;
}
function z(t, e) {
  if (t == null || isNaN(t))
    return "";
  const r = D(e == null ? void 0 : e.locale), c = (e == null ? void 0 : e.currency) || "USD", n = t < 0, i = !!(e != null && e.negativeInParentheses && n), a = i ? Math.abs(t) : t;
  try {
    if (e != null && e.useSuffix) {
      const { divisor: f, suffix: d } = N(a, r), m = a / f, s = `${new Intl.NumberFormat(r, {
        style: "currency",
        currency: c,
        minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
        maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
        useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
      }).format(m)}${d}`;
      return i ? `(${s})` : s;
    }
    const u = new Intl.NumberFormat(r, {
      style: "currency",
      currency: c,
      minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
      maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
      useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
    }).format(a);
    return i ? `(${u})` : u;
  } catch {
    const u = Math.abs(t), f = e != null && e.useSuffix ? N(u, r) : { divisor: 1, suffix: "" }, d = U(
      u / f.divisor,
      {
        locale: r,
        minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
        maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
        useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
      }
    ), m = `${c} ${d}${f.suffix}`;
    return n ? e != null && e.negativeInParentheses ? `(${m})` : `-${m}` : m;
  }
}
function b(t, e) {
  if (t == null || isNaN(t))
    return "";
  const r = D(e == null ? void 0 : e.locale), n = (e == null ? void 0 : e.alreadyPercent) ?? (e == null ? void 0 : e.percentValueMode) === "whole" ? t / 100 : t;
  return new Intl.NumberFormat(r, {
    style: "percent",
    minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
    maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
    useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
  }).format(n);
}
function G(t, e) {
  if (t == null || isNaN(t))
    return "";
  const r = D(e == null ? void 0 : e.locale);
  return new Intl.NumberFormat(r, {
    notation: "scientific",
    minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
    maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2
  }).format(t);
}
function le(t, e, r = "en-US") {
  if (t == null || isNaN(t))
    return "";
  const c = D((e == null ? void 0 : e.locale) || r), n = (e == null ? void 0 : e.style) || "decimal";
  if (n === "percent") {
    const a = ((e == null ? void 0 : e.percentValueMode) ?? "whole") === "whole" ? t / 100 : t;
    return new Intl.NumberFormat(c, {
      style: "percent",
      minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
      maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
      useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
    }).format(a);
  }
  return n === "currency" ? new Intl.NumberFormat(c, {
    style: "currency",
    currency: (e == null ? void 0 : e.currency) || "USD",
    minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
    maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
    useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
  }).format(t) : n === "scientific" ? G(t, {
    locale: c,
    minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
    maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2
  }) : new Intl.NumberFormat(c, {
    minimumFractionDigits: (e == null ? void 0 : e.minimumFractionDigits) ?? 0,
    maximumFractionDigits: (e == null ? void 0 : e.maximumFractionDigits) ?? 2,
    useGrouping: (e == null ? void 0 : e.useGrouping) ?? !0
  }).format(t);
}
function me(t, e, r) {
  const c = {
    style: e === "currency" ? "currency" : e === "percent" ? "percent" : "decimal",
    locale: r == null ? void 0 : r.locale,
    currency: r == null ? void 0 : r.currency,
    minimumFractionDigits: r == null ? void 0 : r.decimalPlaces,
    maximumFractionDigits: r == null ? void 0 : r.decimalPlaces,
    useSuffix: r == null ? void 0 : r.useSuffix,
    prefix: r == null ? void 0 : r.prefix,
    suffix: r == null ? void 0 : r.suffix,
    negativeInParentheses: r == null ? void 0 : r.negativeInParentheses,
    multiplyBy: r == null ? void 0 : r.multiplyBy
  };
  switch (e) {
    case "currency":
      return z(t, c);
    case "percent":
      return b(t, c);
    case "scientific":
      return G(t, c);
    default:
      return U(t, c);
  }
}
const Z = [
  "day",
  "hour",
  "minute",
  "second",
  "millisecond"
], I = {
  day: 864e5,
  hour: 36e5,
  minute: 6e4,
  second: 1e3,
  millisecond: 1
}, o = {
  day: "d",
  hour: "hr",
  minute: "min",
  second: "s",
  millisecond: "ms"
}, p = {
  day: ["day", "days"],
  hour: ["hour", "hours"],
  minute: ["minute", "minutes"],
  second: ["second", "seconds"],
  millisecond: ["millisecond", "milliseconds"]
};
function ee(t) {
  return t === "day" || t === "hour" || t === "minute" || t === "second" || t === "millisecond";
}
function O(t, e) {
  return ee(t) ? t : e;
}
function L(t, e) {
  return Z.indexOf(O(t, e));
}
function te(t, e) {
  const r = L(t, "day"), c = L(e, "second"), n = Math.min(r, c), i = Math.max(r, c);
  return Z.slice(n, i + 1);
}
function re(t, e) {
  return t * I[O(e, "second")];
}
function ce(t, e) {
  const r = te(e.largestUnit, e.smallestUnit), c = r[r.length - 1], n = I[c];
  let i = Math.round(t / n) * n;
  return r.map((a) => {
    const u = I[a], f = Math.floor(i / u);
    return i -= f * u, { unit: a, value: f };
  });
}
function ne(t, e) {
  const r = t.filter((i) => i.value !== 0), c = r.length > 0 ? r : [t[t.length - 1]], n = typeof e == "number" && Number.isFinite(e) ? Math.max(1, Math.trunc(e)) : c.length;
  return c.slice(0, n).map((i) => `${i.value}${o[i.unit]}`).join(" ");
}
function ie(t, e) {
  const r = t.filter((i) => i.value !== 0), c = r.length > 0 ? r : [t[t.length - 1]], n = typeof e == "number" && Number.isFinite(e) ? Math.max(1, Math.trunc(e)) : c.length;
  return c.slice(0, n).map((i) => {
    const [a, u] = p[i.unit];
    return `${i.value} ${i.value === 1 ? a : u}`;
  }).join(" ");
}
function ue(t) {
  const e = t.some(
    (f) => f.unit === "day" && f.value !== 0
  ), r = t.some((f) => f.unit === "millisecond"), c = t.findIndex((f) => f.value !== 0), n = Math.max(0, t.length - 2), i = e ? 0 : c === -1 ? n : Math.min(c, n), a = c === -1 ? t.slice(n) : t.slice(i);
  if (a.length === 0)
    return "0";
  const u = a.map((f, d) => f.unit === "millisecond" ? String(f.value).padStart(3, "0") : d === 0 ? String(f.value) : String(f.value).padStart(2, "0")).join(":");
  return r ? u.replace(/:(\d{3})$/, ".$1") : u;
}
function ae(t, e, r) {
  const c = `${r.prefix || ""}${t}${r.suffix || ""}`;
  return e ? r.negativeInParentheses ? `(${c})` : `-${c}` : c;
}
function de(t, e = {}) {
  if (t == null)
    return "";
  const r = typeof t == "number" ? t : typeof t == "string" && t.trim() ? Number(t) : NaN;
  if (!Number.isFinite(r))
    return "";
  const c = e.inputUnit || "second", n = e.outputStyle === "digital" || e.outputStyle === "long" ? e.outputStyle : "compact", i = r < 0, a = Math.abs(re(r, c)), u = ce(a, e), f = n === "digital" ? ue(u) : n === "long" ? ie(u, e.maxUnits) : ne(u, e.maxUnits);
  return ae(f, i, e);
}
function ge(t, e) {
  return t && t !== "auto" ? t : e;
}
function he(t, e = /* @__PURE__ */ new Date()) {
  try {
    const r = {
      timeZone: t,
      timeZoneName: "short"
    }, n = new Intl.DateTimeFormat("en-US", r).formatToParts(e).find((i) => i.type === "timeZoneName");
    return (n == null ? void 0 : n.value) || t;
  } catch {
    return t;
  }
}
function De(t) {
  try {
    const e = {
      timeZone: t,
      timeZoneName: "long"
    }, c = new Intl.DateTimeFormat("en-US", e).formatToParts(
      /* @__PURE__ */ new Date()
    ).find((n) => n.type === "timeZoneName");
    return (c == null ? void 0 : c.value) || t;
  } catch {
    return t;
  }
}
function _(t, e = "auto") {
  if (!t)
    return /* @__PURE__ */ new Date(NaN);
  const r = t.endsWith("Z"), c = /[+-]\d{2}:?\d{2}$/.test(t), n = /\([A-Z]{3,4}\)$/.test(t);
  if (e === "auto")
    return r || c || n ? new Date(t) : /* @__PURE__ */ new Date(t + "Z");
  if (e === "local") {
    if (r || c) {
      const i = t.replace(/Z$/, "").replace(/[+-]\d{2}:?\d{2}$/, "");
      return new Date(i);
    }
    return new Date(t);
  } else return e === "UTC" ? r ? new Date(t) : c ? new Date(t) : /* @__PURE__ */ new Date(t + "Z") : r || c || n ? new Date(t) : B(t, e);
}
const fe = "MM/dd/yyyy", xe = (t, e, r, c = "auto") => {
  if (!t)
    return "";
  try {
    const n = _(t, c);
    if (isNaN(n.getTime()))
      return t;
    const a = (e && e.trim() ? e : fe).replace(/LLLL/g, "MMMM").replace(/LLL/g, "MMM");
    return r && r !== "auto" ? R(n, r, a) : X(n, a);
  } catch (n) {
    return console.error("Date formatting error:", n), t;
  }
}, Me = (t, e = "auto") => {
  if (!t)
    return "";
  try {
    const r = _(t, e);
    return isNaN(r.getTime()) ? t : Q(r, { addSuffix: !0 });
  } catch (r) {
    return console.error("Relative time formatting error:", r), t;
  }
};
export {
  Me as a,
  xe as b,
  U as c,
  z as d,
  b as e,
  le as f,
  G as g,
  me as h,
  de as i,
  he as j,
  De as k,
  Q as l,
  _ as p,
  ge as r
};
