import { jsxs, jsx } from "react/jsx-runtime";
import { useMemo } from "react";
import moment from "moment";
import FormControl from "../../node_modules/@mui/material/FormControl/FormControl.js";
import Select from "../../node_modules/@mui/material/Select/Select.js";
import MenuItem from "../../node_modules/@mui/material/MenuItem/MenuItem.js";
const DEFAULT_YEARS_COUNT = 10;
function ShowMonthYearSelect({
  customYears,
  month,
  onMonthSelect,
  onYearSelect,
  minDate,
  maxDate
}) {
  const years = useMemo(() => {
    if (customYears && customYears.length > 0) {
      return customYears;
    }
    if (minDate && maxDate) {
      const start = minDate.year();
      const end = maxDate.year();
      return Array.from({ length: end - start + 1 }, (_, i) => {
        const y = (start + i).toString();
        return { label: y, value: y };
      });
    }
    const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
    return Array.from({ length: DEFAULT_YEARS_COUNT }, (_, i) => {
      const y = (currentYear - 5 + i).toString();
      return { label: y, value: y };
    });
  }, [customYears, minDate, maxDate]);
  const months = useMemo(
    () => moment.months().map((label, value) => ({
      label,
      value: value.toString()
    })),
    []
  );
  const monthValue = month.month().toString();
  const yearValue = month.year().toString();
  return /* @__PURE__ */ jsxs("div", { className: "date-picker-show-month-year-select-container", children: [
    /* @__PURE__ */ jsx("div", { className: "date-picker-month-select-container", children: /* @__PURE__ */ jsx(FormControl, { size: "small", sx: { minWidth: 105 }, children: /* @__PURE__ */ jsx(
      Select,
      {
        displayEmpty: true,
        id: "date-picker-month-select",
        size: "small",
        sx: { height: 32, fontSize: 14 },
        value: monthValue,
        onChange: (e) => {
          onMonthSelect(month, e.target.value);
        },
        children: months.map((m) => /* @__PURE__ */ jsx(MenuItem, { value: m.value, children: m.label }, m.value))
      }
    ) }) }),
    /* @__PURE__ */ jsx("div", { className: "date-picker-year-select-container", children: /* @__PURE__ */ jsx(FormControl, { size: "small", sx: { minWidth: 80 }, children: /* @__PURE__ */ jsx(
      Select,
      {
        displayEmpty: true,
        id: "date-picker-year-select",
        size: "small",
        sx: { height: 32, fontSize: 14 },
        value: yearValue,
        onChange: (e) => {
          onYearSelect(month, e.target.value);
        },
        children: years.map((y) => /* @__PURE__ */ jsx(MenuItem, { value: y.value, children: y.label }, y.value))
      }
    ) }) })
  ] });
}
export {
  ShowMonthYearSelect
};
