import n from "../../../dayjs/dayjs.min.mjs";
import { noteOnce as p } from "../../../rc-util/es/warning.mjs";
import y from "../../../dayjs/plugin/weekday.mjs";
import k from "../../../dayjs/plugin/localeData.mjs";
import Y from "../../../dayjs/plugin/weekOfYear.mjs";
import v from "../../../dayjs/plugin/weekYear.mjs";
import M from "../../../dayjs/plugin/advancedFormat.mjs";
import W from "../../../dayjs/plugin/customParseFormat.mjs";
n.extend(W);
n.extend(M);
n.extend(y);
n.extend(k);
n.extend(Y);
n.extend(v);
n.extend(function(r, e) {
  var t = e.prototype, o = t.format;
  t.format = function(u) {
    var i = (u || "").replace("Wo", "wo");
    return o.bind(this)(i);
  };
});
var _ = {
  // ar_EG:
  // az_AZ:
  // bg_BG:
  bn_BD: "bn-bd",
  by_BY: "be",
  // ca_ES:
  // cs_CZ:
  // da_DK:
  // de_DE:
  // el_GR:
  en_GB: "en-gb",
  en_US: "en",
  // es_ES:
  // et_EE:
  // fa_IR:
  // fi_FI:
  fr_BE: "fr",
  // todo: dayjs has no fr_BE locale, use fr at present
  fr_CA: "fr-ca",
  // fr_FR:
  // ga_IE:
  // gl_ES:
  // he_IL:
  // hi_IN:
  // hr_HR:
  // hu_HU:
  hy_AM: "hy-am",
  // id_ID:
  // is_IS:
  // it_IT:
  // ja_JP:
  // ka_GE:
  // kk_KZ:
  // km_KH:
  kmr_IQ: "ku",
  // kn_IN:
  // ko_KR:
  // ku_IQ: // previous ku in antd
  // lt_LT:
  // lv_LV:
  // mk_MK:
  // ml_IN:
  // mn_MN:
  // ms_MY:
  // nb_NO:
  // ne_NP:
  nl_BE: "nl-be",
  // nl_NL:
  // pl_PL:
  pt_BR: "pt-br",
  // pt_PT:
  // ro_RO:
  // ru_RU:
  // sk_SK:
  // sl_SI:
  // sr_RS:
  // sv_SE:
  // ta_IN:
  // th_TH:
  // tr_TR:
  // uk_UA:
  // ur_PK:
  // vi_VN:
  zh_CN: "zh-cn",
  zh_HK: "zh-hk",
  zh_TW: "zh-tw"
}, a = function(e) {
  var t = _[e];
  return t || e.split("_")[0];
}, h = function() {
  p(!1, "Not match any format. Please help to fire a issue about this.");
}, O = {
  // get
  getNow: function() {
    return n();
  },
  getFixedDate: function(e) {
    return n(e, ["YYYY-M-DD", "YYYY-MM-DD"]);
  },
  getEndDate: function(e) {
    return e.endOf("month");
  },
  getWeekDay: function(e) {
    var t = e.locale("en");
    return t.weekday() + t.localeData().firstDayOfWeek();
  },
  getYear: function(e) {
    return e.year();
  },
  getMonth: function(e) {
    return e.month();
  },
  getDate: function(e) {
    return e.date();
  },
  getHour: function(e) {
    return e.hour();
  },
  getMinute: function(e) {
    return e.minute();
  },
  getSecond: function(e) {
    return e.second();
  },
  // set
  addYear: function(e, t) {
    return e.add(t, "year");
  },
  addMonth: function(e, t) {
    return e.add(t, "month");
  },
  addDate: function(e, t) {
    return e.add(t, "day");
  },
  setYear: function(e, t) {
    return e.year(t);
  },
  setMonth: function(e, t) {
    return e.month(t);
  },
  setDate: function(e, t) {
    return e.date(t);
  },
  setHour: function(e, t) {
    return e.hour(t);
  },
  setMinute: function(e, t) {
    return e.minute(t);
  },
  setSecond: function(e, t) {
    return e.second(t);
  },
  // Compare
  isAfter: function(e, t) {
    return e.isAfter(t);
  },
  isValidate: function(e) {
    return e.isValid();
  },
  locale: {
    getWeekFirstDay: function(e) {
      return n().locale(a(e)).localeData().firstDayOfWeek();
    },
    getWeekFirstDate: function(e, t) {
      return t.locale(a(e)).weekday(0);
    },
    getWeek: function(e, t) {
      return t.locale(a(e)).week();
    },
    getShortWeekDays: function(e) {
      return n().locale(a(e)).localeData().weekdaysMin();
    },
    getShortMonths: function(e) {
      return n().locale(a(e)).localeData().monthsShort();
    },
    format: function(e, t, o) {
      return t.locale(a(e)).format(o);
    },
    parse: function(e, t, o) {
      for (var c = a(e), u = 0; u < o.length; u += 1) {
        var i = o[u], f = t;
        if (i.includes("wo") || i.includes("Wo")) {
          for (var g = f.split("-")[0], m = f.split("-")[1], D = n(g, "YYYY").startOf("year").locale(c), l = 0; l <= 52; l += 1) {
            var d = D.add(l, "week");
            if (d.format("Wo") === m)
              return d;
          }
          return h(), null;
        }
        var s = n(f, i, !0).locale(c);
        if (s.isValid())
          return s;
      }
      return t && h(), null;
    }
  }
};
export {
  O as default
};
