var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
  calcDateNum: () => calcDateNum,
  cloneDate: () => cloneDate,
  cloneDates: () => cloneDates,
  compareDay: () => compareDay,
  compareMonth: () => compareMonth,
  formatMonthTitle: () => formatMonthTitle,
  getDayByOffset: () => getDayByOffset,
  getMonthEndDay: () => getMonthEndDay,
  getNextDay: () => getNextDay,
  getPrevDay: () => getPrevDay,
  getToday: () => getToday,
  t: () => t
});
module.exports = __toCommonJS(stdin_exports);
function compareMonth(date1, date2) {
  const year1 = date1.getFullYear();
  const year2 = date2.getFullYear();
  if (year1 === year2) {
    const month1 = date1.getMonth();
    const month2 = date2.getMonth();
    return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
  }
  return year1 > year2 ? 1 : -1;
}
function compareDay(day1, day2) {
  const compareMonthResult = compareMonth(day1, day2);
  if (compareMonthResult === 0) {
    const date1 = day1.getDate();
    const date2 = day2.getDate();
    return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
  }
  return compareMonthResult;
}
const cloneDate = (date) => new Date(date);
const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
function getDayByOffset(date, offset) {
  const cloned = cloneDate(date);
  cloned.setDate(cloned.getDate() + offset);
  return cloned;
}
const getPrevDay = (date) => getDayByOffset(date, -1);
const getNextDay = (date) => getDayByOffset(date, 1);
const getToday = () => {
  const today = new Date();
  today.setHours(0, 0, 0, 0);
  return today;
};
function calcDateNum(date) {
  const day1 = date[0].getTime();
  const day2 = date[1].getTime();
  return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
}
const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
const calendarLang = {
  end: "\u7ED3\u675F",
  start: "\u5F00\u59CB",
  title: "\u65E5\u671F\u9009\u62E9",
  confirm: "\u786E\u5B9A",
  startEnd: "\u5F00\u59CB/\u7ED3\u675F",
  weekdays: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"],
  monthTitle: (year, month) => `${year}\u5E74${month}\u6708`,
  rangePrompt: (maxRange) => `\u6700\u591A\u9009\u62E9 ${maxRange} \u5929`
};
const t = (key, ...args) => {
  if (args.length) {
    return calendarLang[key](...args);
  }
  return calendarLang[key];
};
const formatMonthTitle = (date) => t("monthTitle", date.getFullYear(), date.getMonth() + 1);
