import { DECADE_UNIT_DIFF as i } from "../panels/DecadePanel/constant.mjs";
var F = 7;
function n(e, t) {
  if (!e && !t)
    return !0;
  if (!e || !t)
    return !1;
}
function w(e, t, r) {
  var a = n(t, r);
  if (typeof a == "boolean")
    return a;
  var o = Math.floor(e.getYear(t) / 10), u = Math.floor(e.getYear(r) / 10);
  return o === u;
}
function D(e, t, r) {
  var a = n(t, r);
  return typeof a == "boolean" ? a : e.getYear(t) === e.getYear(r);
}
function v(e, t) {
  var r = Math.floor(e.getMonth(t) / 3);
  return r + 1;
}
function A(e, t, r) {
  var a = n(t, r);
  return typeof a == "boolean" ? a : D(e, t, r) && v(e, t) === v(e, r);
}
function I(e, t, r) {
  var a = n(t, r);
  return typeof a == "boolean" ? a : D(e, t, r) && e.getMonth(t) === e.getMonth(r);
}
function f(e, t, r) {
  var a = n(t, r);
  return typeof a == "boolean" ? a : e.getYear(t) === e.getYear(r) && e.getMonth(t) === e.getMonth(r) && e.getDate(t) === e.getDate(r);
}
function q(e, t, r) {
  var a = n(t, r);
  return typeof a == "boolean" ? a : e.getHour(t) === e.getHour(r) && e.getMinute(t) === e.getMinute(r) && e.getSecond(t) === e.getSecond(r);
}
function N(e, t, r, a) {
  var o = n(r, a);
  return typeof o == "boolean" ? o : D(e, r, a) && e.locale.getWeek(t, r) === e.locale.getWeek(t, a);
}
function R(e, t, r) {
  return f(e, t, r) && q(e, t, r);
}
function T(e, t, r, a) {
  return !t || !r || !a ? !1 : !f(e, t, a) && !f(e, r, a) && e.isAfter(a, t) && e.isAfter(r, a);
}
function V(e, t, r) {
  var a = t.locale.getWeekFirstDay(e), o = t.setDate(r, 1), u = t.getWeekDay(o), l = t.addDate(o, a - u);
  return t.getMonth(l) === t.getMonth(r) && t.getDate(l) > 1 && (l = t.addDate(l, -7)), l;
}
function H(e, t, r) {
  var a = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 1;
  switch (t) {
    case "year":
      return r.addYear(e, a * 10);
    case "quarter":
    case "month":
      return r.addYear(e, a);
    default:
      return r.addMonth(e, a);
  }
}
function L(e, t) {
  var r = t.generateConfig, a = t.locale, o = t.format;
  return typeof o == "function" ? o(e) : r.locale.format(a.locale, e, o);
}
function Q(e, t) {
  var r = t.generateConfig, a = t.locale, o = t.formatList;
  return !e || typeof o[0] == "function" ? null : r.locale.parse(a.locale, e, o);
}
function d(e) {
  var t = e.cellDate, r = e.mode, a = e.disabledDate, o = e.generateConfig;
  if (!a)
    return !1;
  var u = function(k, S, Y) {
    for (var c = S; c <= Y; ) {
      var s = void 0;
      switch (k) {
        case "date": {
          if (s = o.setDate(t, c), !a(s))
            return !1;
          break;
        }
        case "month": {
          if (s = o.setMonth(t, c), !d({
            cellDate: s,
            mode: "month",
            generateConfig: o,
            disabledDate: a
          }))
            return !1;
          break;
        }
        case "year": {
          if (s = o.setYear(t, c), !d({
            cellDate: s,
            mode: "year",
            generateConfig: o,
            disabledDate: a
          }))
            return !1;
          break;
        }
      }
      c += 1;
    }
    return !0;
  };
  switch (r) {
    case "date":
    case "week":
      return a(t);
    case "month": {
      var l = 1, b = o.getDate(o.getEndDate(t));
      return u("date", l, b);
    }
    case "quarter": {
      var m = Math.floor(o.getMonth(t) / 3) * 3, M = m + 2;
      return u("month", m, M);
    }
    case "year":
      return u("month", 0, 11);
    case "decade": {
      var y = o.getYear(t), h = Math.floor(y / i) * i, p = h + i - 1;
      return u("year", h, p);
    }
  }
}
export {
  F as WEEK_DAY_COUNT,
  L as formatValue,
  d as getCellDateDisabled,
  H as getClosingViewDate,
  v as getQuarter,
  V as getWeekStartDate,
  R as isEqual,
  T as isInRange,
  n as isNullEqual,
  f as isSameDate,
  w as isSameDecade,
  I as isSameMonth,
  A as isSameQuarter,
  q as isSameTime,
  N as isSameWeek,
  D as isSameYear,
  Q as parseValue
};
