"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index$1 = require("../../../hooks/use-locale/index.js");
const index = require("../../../hooks/use-namespace/index.js");
const index$2 = require("../../button/index.js");
const calendar = require("./calendar.js");
const dateTable2 = require("./date-table2.js");
const useCalendar = require("./use-calendar.js");
const selectController2 = require("./select-controller2.js");
const Vue = require("vue");
const COMPONENT_NAME = "ElCalendar";
var calendar_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Vue.defineComponent({
  name: COMPONENT_NAME,
  __name: "calendar",
  props: calendar.calendarProps,
  emits: calendar.calendarEmits,
  setup(__props, { expose: __expose, emit: __emit }) {
    const ns = index.useNamespace("calendar");
    const { calculateValidatedDateRange, date, pickDay, realSelectedDay, selectDate, validatedRange, handleDateChange } = useCalendar.useCalendar(__props, __emit, COMPONENT_NAME);
    const { t } = index$1.useLocale();
    const i18nDate = Vue.computed(() => {
      const pickedMonth = `el.datepicker.month${date.value.format("M")}`;
      return `${date.value.year()} ${t("el.datepicker.year")} ${t(pickedMonth)}`;
    });
    __expose({
      selectedDay: realSelectedDay,
      pickDay,
      selectDate,
      calculateValidatedDateRange
    });
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createElementBlock("div", { class: Vue.normalizeClass(Vue.unref(ns).b()) }, [Vue.createElementVNode("div", { class: Vue.normalizeClass(Vue.unref(ns).e("header")) }, [Vue.renderSlot(_ctx.$slots, "header", { date: i18nDate.value }, () => [Vue.createElementVNode("div", { class: Vue.normalizeClass(Vue.unref(ns).e("title")) }, Vue.toDisplayString(i18nDate.value), 3), Vue.unref(validatedRange).length === 0 && __props.controllerType === "button" ? (Vue.openBlock(), Vue.createElementBlock("div", {
        key: 0,
        class: Vue.normalizeClass(Vue.unref(ns).e("button-group"))
      }, [Vue.createVNode(Vue.unref(index$2.ElButtonGroup), null, {
        default: Vue.withCtx(() => [
          Vue.createVNode(Vue.unref(index$2.ElButton), {
            size: "small",
            onClick: _cache[0] || (_cache[0] = ($event) => Vue.unref(selectDate)("prev-month"))
          }, {
            default: Vue.withCtx(() => [Vue.createTextVNode(Vue.toDisplayString(Vue.unref(t)("el.datepicker.prevMonth")), 1)]),
            _: 1
          }),
          Vue.createVNode(Vue.unref(index$2.ElButton), {
            size: "small",
            onClick: _cache[1] || (_cache[1] = ($event) => Vue.unref(selectDate)("today"))
          }, {
            default: Vue.withCtx(() => [Vue.createTextVNode(Vue.toDisplayString(Vue.unref(t)("el.datepicker.today")), 1)]),
            _: 1
          }),
          Vue.createVNode(Vue.unref(index$2.ElButton), {
            size: "small",
            onClick: _cache[2] || (_cache[2] = ($event) => Vue.unref(selectDate)("next-month"))
          }, {
            default: Vue.withCtx(() => [Vue.createTextVNode(Vue.toDisplayString(Vue.unref(t)("el.datepicker.nextMonth")), 1)]),
            _: 1
          })
        ]),
        _: 1
      })], 2)) : Vue.unref(validatedRange).length === 0 && __props.controllerType === "select" ? (Vue.openBlock(), Vue.createElementBlock("div", {
        key: 1,
        class: Vue.normalizeClass(Vue.unref(ns).e("select-controller"))
      }, [Vue.createVNode(selectController2.default, {
        date: Vue.unref(date),
        formatter: __props.formatter,
        onDateChange: Vue.unref(handleDateChange)
      }, null, 8, [
        "date",
        "formatter",
        "onDateChange"
      ])], 2)) : Vue.createCommentVNode("v-if", true)])], 2), Vue.unref(validatedRange).length === 0 ? (Vue.openBlock(), Vue.createElementBlock("div", {
        key: 0,
        class: Vue.normalizeClass(Vue.unref(ns).e("body"))
      }, [Vue.createVNode(dateTable2.default, {
        date: Vue.unref(date),
        "selected-day": Vue.unref(realSelectedDay),
        onPick: Vue.unref(pickDay)
      }, Vue.createSlots({ _: 2 }, [_ctx.$slots["date-cell"] ? {
        name: "date-cell",
        fn: Vue.withCtx((data) => [Vue.renderSlot(_ctx.$slots, "date-cell", Vue.normalizeProps(Vue.guardReactiveProps(data)))]),
        key: "0"
      } : void 0]), 1032, [
        "date",
        "selected-day",
        "onPick"
      ])], 2)) : (Vue.openBlock(), Vue.createElementBlock("div", {
        key: 1,
        class: Vue.normalizeClass(Vue.unref(ns).e("body"))
      }, [(Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(validatedRange), (range_, index2) => {
        return Vue.openBlock(), Vue.createBlock(dateTable2.default, {
          key: index2,
          date: range_[0],
          "selected-day": Vue.unref(realSelectedDay),
          range: range_,
          "hide-header": index2 !== 0,
          onPick: Vue.unref(pickDay)
        }, Vue.createSlots({ _: 2 }, [_ctx.$slots["date-cell"] ? {
          name: "date-cell",
          fn: Vue.withCtx((data) => [Vue.renderSlot(_ctx.$slots, "date-cell", Vue.mergeProps({ ref_for: true }, data))]),
          key: "0"
        } : void 0]), 1032, [
          "date",
          "selected-day",
          "range",
          "hide-header",
          "onPick"
        ]);
      }), 128))], 2))], 2);
    };
  }
});
exports.default = calendar_vue_vue_type_script_setup_true_lang_default;
