import { getTimeFormatToZone as u, userTimezone as O } from "@aplus-frontend/utils";
import l from "dayjs";
const s = (t, e = l().valueOf()) => l(u(e, t ?? O)), m = (t, e) => {
  const a = s(t, e);
  return [a.startOf("day"), a.endOf("day")];
}, c = (t, e) => {
  const a = s(t, e);
  return [
    a.startOf("day").subtract(1, "day").startOf("day"),
    a.endOf("day").subtract(1, "day").endOf("day")
  ];
}, h = (t, e) => {
  const a = s(t, e);
  return [
    a.startOf("week").startOf("day"),
    a.endOf("week").endOf("day")
  ];
}, p = (t, e) => {
  const a = s(t, e);
  return [
    a.subtract(1, "week").startOf("week").startOf("day"),
    a.subtract(1, "week").endOf("week").endOf("day")
  ];
}, i = (t, e) => {
  const a = s(t, e);
  return [
    a.startOf("month").startOf("day"),
    a.endOf("month").endOf("day")
  ];
}, b = (t, e) => {
  const a = s(t, e);
  return [
    a.subtract(1, "month").startOf("month").startOf("day"),
    a.subtract(1, "month").endOf("month").endOf("day")
  ];
}, T = (t, e) => {
  const a = s(t, e), r = a.month(), o = Math.floor(r / 3), d = a.month(o * 3).date(1).startOf("day"), n = d.add(2, "month").endOf("month").endOf("day");
  return [d, n];
}, v = (t, e) => {
  const r = s(t, e).subtract(3, "month"), o = r.month(), d = Math.floor(o / 3), n = r.clone().month(d * 3).date(1).startOf("day"), y = n.clone().add(2, "month").endOf("month").endOf("day");
  return [n, y];
}, G = (t, e) => {
  const a = s(t, e);
  return [
    a.startOf("year").startOf("day"),
    a.endOf("year").endOf("day")
  ];
}, k = (t, e) => {
  const a = s(t, e);
  return [
    a.subtract(1, "year").startOf("year").startOf("day"),
    a.subtract(1, "year").endOf("year").endOf("day")
  ];
}, f = (t, e, a) => {
  const r = s(e, a);
  return [
    r.subtract(t - 1, "day").startOf("day"),
    r.endOf("day")
  ];
}, Q = (t, e, a) => [
  {
    label: a ? a("ap.field.today") : "今天",
    value: m(t, e)
  },
  {
    label: a ? a("ap.field.yesterday") : "昨天",
    value: c(t, e)
  },
  {
    label: a ? a("ap.field.thisWeek") : "本周",
    value: h(t, e)
  },
  {
    label: a ? a("ap.field.lastWeek") : "上周",
    value: p(t, e)
  },
  {
    label: a ? a("ap.field.lastXDays", { day: 7 }) : "近7天",
    value: f(7, t, e)
  },
  {
    label: a ? a("ap.field.lastXDays", { day: 30 }) : "近30天",
    value: f(30, t, e)
  },
  {
    label: a ? a("ap.field.lastXDays", { day: 90 }) : "近90天",
    value: f(90, t, e)
  },
  {
    label: a ? a("ap.field.thisMonth") : "本月",
    value: i(t, e)
  },
  {
    label: a ? a("ap.field.lastMonth") : "上月",
    value: b(t, e)
  },
  {
    label: a ? a("ap.field.thisQuarter") : "本季度",
    value: T(t, e)
  },
  {
    label: a ? a("ap.field.lastQuarter") : "上季度",
    value: v(t, e)
  },
  {
    label: a ? a("ap.field.thisYear") : "本年",
    value: G(t, e)
  },
  {
    label: a ? a("ap.field.lastYear") : "去年",
    value: k(t, e)
  }
];
export {
  Q as presetsDefault,
  b as presetsGetLastMonth,
  v as presetsGetLastQuarter,
  p as presetsGetLastWeek,
  f as presetsGetLastXDays,
  k as presetsGetLastYear,
  i as presetsGetThisMonth,
  T as presetsGetThisQuarter,
  h as presetsGetThisWeek,
  G as presetsGetThisYear,
  s as presetsGetTimezoneFormat,
  m as presetsGetToday,
  c as presetsGetYesterday
};
