var D = Object.defineProperty;
var l = (o, e, t) => e in o ? D(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
var n = (o, e, t) => (l(o, typeof e != "symbol" ? e + "" : e, t), t);
import m from "./index.es78.js";
import "./index.es79.js";
const d = "en", u = 31, i = class i {
  /**
   * Constructs a new calendar instance for the passed locale and calendar.
   *
   * @param locale
   * @param name
   */
  constructor(e = d, t = i.Calendars.gregorian) {
    n(this, "locale");
    n(this, "name");
    this.locale = e, this.name = t;
  }
  /**
   * Increments the date by the passed value.
   *
   * @param date
   * @param value
   *
   * @returns {*}
   */
  addDate(e, t) {
    const a = this.moment(e);
    return this.isHijri() ? a.add(t, "iDate") : a.add(t, "date");
  }
  /**
   * Increments the month by the passed value.
   *
   * @param date
   * @param value
   *
   * @returns {*}
   */
  addMonth(e, t) {
    const a = this.moment(e);
    return this.isHijri() ? a.add(t, "iMonth") : a.add(t, "month");
  }
  /**
   * Increments the year by the passed value.
   *
   * @param date
   * @param value
   *
   * @returns {*}
   */
  addYear(e, t) {
    const a = this.moment(e);
    return this.isHijri() ? a.add(t, "iYear") : a.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: e, month: t, date: a }) {
    let r = this.moment().hours(0).minutes(0).seconds(0);
    return this.isHijri() ? r = r.iYear(e || this.getDefaultYear()).iMonth(t || this.getDefaultMonth()).iDate(a || this.getDefaultDate()) : r = r.year(e || this.getDefaultYear()).month(t || this.getDefaultMonth()).date(a || this.getDefaultDate()), r;
  }
  /**
   * Returns the days in the month for the passed year/month.
   *
   * @param year
   * @param month
   *
   * @returns {number}
   */
  daysInMonth(e, t) {
    const a = e || this.getDefaultYear(), r = t || this.getDefaultMonth(), h = this.convertToDate({ year: a, month: r, date: this.getDefaultDate() });
    return (this.isHijri() ? h.iDaysInMonth() : h.daysInMonth()) || u;
  }
  /**
   * Formats the passed date.
   *
   * @param date
   * @param format
   *
   * @returns {*}
   */
  format(e, t = i.DateFormats.gregorian) {
    return this.moment(e).format(i.DateFormats[this.name][t]);
  }
  /**
   * Returns the default date for the current calendar.
   *
   * @returns {*}
   */
  getDefaultDate() {
    return i.Defaults[this.name].date;
  }
  /**
   * Returns the default month for the current calendar.
   *
   * @returns {*}
   */
  getDefaultMonth() {
    return i.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 i.Defaults[this.name].year;
  }
  /**
   * Returns true if the current calendar is Hijri.
   *
   * @returns {boolean}
   */
  isHijri() {
    return this.name === i.Calendars.hijri;
  }
  /**
   * Returns the list of months for the current calendar.
   *
   * @returns {*}
   */
  listMonths() {
    const e = this.moment().localeData();
    return this.isHijri() ? e._iMonths : e.months();
  }
  /**
   * Wraps the passed date/string in a moment object.
   *
   * @param date
   */
  moment(e = null) {
    const t = e ? m(e) : m();
    return t.locale(this.locale), t;
  }
  /**
   * Parses the passed date into year, month, and date components.
   *
   * @param date
   *
   * @returns {{date: (*), month: (*), year: (*)}}
   */
  parseDate(e) {
    const t = this.moment(e);
    return {
      year: this.isHijri() ? t.iYear() : t.year(),
      month: this.isHijri() ? t.iMonth() : t.month(),
      date: this.isHijri() ? t.iDate() : t.date()
    };
  }
};
n(i, "Calendars"), n(i, "DateFormats"), n(i, "Defaults");
let s = i;
s.Calendars = {
  gregorian: "gregorian",
  hijri: "hijri"
};
s.DateFormats = {
  [s.Calendars.gregorian]: {
    0: "YYYY",
    1: "MMMM YYYY",
    2: "L"
  },
  [s.Calendars.hijri]: {
    0: "iYYYY",
    1: "iMMMM iYYYY",
    2: "iM/iD/iYYYY"
  }
};
s.Defaults = {
  [s.Calendars.gregorian]: {
    year: 0,
    month: 0,
    date: 1
  },
  [s.Calendars.hijri]: {
    year: 1410,
    month: 0,
    date: 1
  }
};
export {
  s as default
};
//# sourceMappingURL=index.es22.js.map
