import s from "./index.es81.js";
import "./index.es82.js";
import n from "./index.es39.js";
import "./index.es40.js";
import "./index.es41.js";
import "./index.es42.js";
import "./index.es43.js";
import "./index.es44.js";
import "./index.es45.js";
import "./index.es46.js";
import "./index.es47.js";
import "./index.es48.js";
import "./index.es49.js";
import "./index.es50.js";
import "./index.es51.js";
import "./index.es52.js";
import "./index.es53.js";
import "./index.es54.js";
import "./index.es55.js";
import "./index.es56.js";
import "./index.es57.js";
import "./index.es58.js";
import "./index.es59.js";
import "./index.es60.js";
import "./index.es61.js";
import "./index.es62.js";
import "./index.es63.js";
import "./index.es64.js";
import "./index.es65.js";
import "./index.es66.js";
const m = "en", h = 31;
class r {
  static Calendars;
  static DateFormats;
  static Defaults;
  locale;
  name;
  /**
   * Constructs a new calendar instance for the passed locale and calendar.
   *
   * @param locale
   * @param name
   */
  constructor(i = m, t = r.Calendars.gregorian) {
    this.locale = i, this.name = t;
  }
  /**
   * Increments the date by the passed value.
   *
   * @param date
   * @param value
   *
   * @returns {*}
   */
  addDate(i, t) {
    const e = this.moment(i);
    return this.isHijri() ? e.add(t, "iDate") : e.add(t, "date");
  }
  /**
   * Increments the month by the passed value.
   *
   * @param date
   * @param value
   *
   * @returns {*}
   */
  addMonth(i, t) {
    const e = this.moment(i);
    return this.isHijri() ? e.add(t, "iMonth") : e.add(t, "month");
  }
  /**
   * Increments the year by the passed value.
   *
   * @param date
   * @param value
   *
   * @returns {*}
   */
  addYear(i, t) {
    const e = this.moment(i);
    return this.isHijri() ? e.add(t, "iYear") : e.add(t, "year");
  }
  /**
   * Converts the passed year, month, and date to a moment Date object.
   *
   * @param year
   * @param month
   * @param date
   *
   * @returns {moment.Moment}
   */
  convertToDate({ year: i, month: t, date: e }) {
    let a = this.moment().hours(0).minutes(0).seconds(0);
    return this.isHijri() ? a = a.iYear(i || this.getDefaultYear()).iMonth(t || this.getDefaultMonth()).iDate(e || this.getDefaultDate()) : a = a.year(i || this.getDefaultYear()).month(t || this.getDefaultMonth()).date(e || this.getDefaultDate()), a;
  }
  /**
   * Returns the days in the month for the passed year/month.
   *
   * @param year
   * @param month
   *
   * @returns {number}
   */
  daysInMonth(i, t) {
    const e = i || this.getDefaultYear(), a = t || this.getDefaultMonth(), o = this.convertToDate({ year: e, month: a, date: this.getDefaultDate() });
    return (this.isHijri() ? o.iDaysInMonth() : o.daysInMonth()) || h;
  }
  /**
   * Formats the passed date.
   *
   * @param date
   * @param format
   *
   * @returns {*}
   */
  format(i, t = r.DateFormats.gregorian) {
    return this.moment(i).format(r.DateFormats[this.name][t]);
  }
  /**
   * Returns the default date for the current calendar.
   *
   * @returns {*}
   */
  getDefaultDate() {
    return r.Defaults[this.name].date;
  }
  /**
   * Returns the default month for the current calendar.
   *
   * @returns {*}
   */
  getDefaultMonth() {
    return r.Defaults[this.name].month;
  }
  /**
   * Returns the default year for the current calendar.
   *
   * @returns {number|*|"numeric"|"2-digit"|string|((y: number) => moment.Moment)|(() => number)|moment.numberlike}
   */
  getDefaultYear() {
    return r.Defaults[this.name].year;
  }
  /**
   * Returns true if the current calendar is Hijri.
   *
   * @returns {boolean}
   */
  isHijri() {
    return this.name === r.Calendars.hijri;
  }
  /**
   * Returns the list of months for the current calendar.
   *
   * @returns {*}
   */
  listMonths() {
    const i = this.moment().localeData();
    return this.isHijri() ? i._iMonths : i.months();
  }
  /**
   * Parses the passed date string for use with Moment, handling negative dates.
   *
   * @param dateString
   */
  parseNegative(i) {
    const t = i.match(/^-(\d{4})(-\d{2}-\d{2})$/);
    if (!t)
      return i;
    const [e, a, o] = t;
    return `-${a.padStart(6, "0")}${o}`;
  }
  /**
   * Wraps the passed date/string in a moment object.
   *
   * @param date
   */
  moment(i = null) {
    const t = n.isString(i) ? this.parseNegative(i) : i, e = t ? s(t) : s();
    return e.locale(this.locale), e;
  }
  /**
   * Parses the passed date into year, month, and date components.
   *
   * @param date
   *
   * @returns {{date: (*), month: (*), year: (*)}}
   */
  parseDate(i) {
    const t = this.moment(i);
    return {
      year: this.isHijri() ? t.iYear() : t.year(),
      month: this.isHijri() ? t.iMonth() : t.month(),
      date: this.isHijri() ? t.iDate() : t.date()
    };
  }
}
r.Calendars = {
  gregorian: "gregorian",
  hijri: "hijri"
};
r.DateFormats = {
  [r.Calendars.gregorian]: {
    0: "YYYY",
    1: "MMMM YYYY",
    2: "L"
  },
  [r.Calendars.hijri]: {
    0: "iYYYY",
    1: "iMMMM iYYYY",
    2: "iM/iD/iYYYY"
  }
};
r.Defaults = {
  [r.Calendars.gregorian]: {
    year: 0,
    month: 0,
    date: 1
  },
  [r.Calendars.hijri]: {
    year: 1410,
    month: 0,
    date: 1
  }
};
export {
  r as default
};
//# sourceMappingURL=index.es23.js.map
