"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index = require("../../../hooks/use-namespace/index.js");
const dateTable = require("./date-table.js");
const useDateTable = require("./use-date-table.js");
const Vue = require("vue");
const _hoisted_1 = { key: 0 };
const _hoisted_2 = ["onClick"];
var date_table_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Vue.defineComponent({
  name: "DateTable",
  __name: "date-table",
  props: dateTable.dateTableProps,
  emits: dateTable.dateTableEmits,
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const { isInRange, now, rows, weekDays, getFormattedDate, handlePickDay, getSlotData } = useDateTable.useDateTable(props, __emit);
    const nsTable = index.useNamespace("calendar-table");
    const nsDay = index.useNamespace("calendar-day");
    const getCellClass = ({ text, type }) => {
      const classes = [type];
      if (type === "current") {
        const date = getFormattedDate(text, type);
        if (date.isSame(props.selectedDay, "day")) classes.push(nsDay.is("selected"));
        if (date.isSame(now, "day")) classes.push(nsDay.is("today"));
      }
      return classes;
    };
    __expose({ getFormattedDate });
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createElementBlock("table", {
        class: Vue.normalizeClass([Vue.unref(nsTable).b(), Vue.unref(nsTable).is("range", Vue.unref(isInRange))]),
        cellspacing: "0",
        cellpadding: "0"
      }, [!__props.hideHeader ? (Vue.openBlock(), Vue.createElementBlock("thead", _hoisted_1, [Vue.createElementVNode("tr", null, [(Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(weekDays), (day) => {
        return Vue.openBlock(), Vue.createElementBlock("th", {
          key: day,
          scope: "col"
        }, Vue.toDisplayString(day), 1);
      }), 128))])])) : Vue.createCommentVNode("v-if", true), Vue.createElementVNode("tbody", null, [(Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(rows), (row, index2) => {
        return Vue.openBlock(), Vue.createElementBlock("tr", {
          key: index2,
          class: Vue.normalizeClass({
            [Vue.unref(nsTable).e("row")]: true,
            [Vue.unref(nsTable).em("row", "hide-border")]: index2 === 0 && __props.hideHeader
          })
        }, [(Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(row, (cell, key) => {
          return Vue.openBlock(), Vue.createElementBlock("td", {
            key,
            class: Vue.normalizeClass(getCellClass(cell)),
            onClick: ($event) => Vue.unref(handlePickDay)(cell)
          }, [Vue.createElementVNode("div", { class: Vue.normalizeClass(Vue.unref(nsDay).b()) }, [Vue.renderSlot(_ctx.$slots, "date-cell", { data: Vue.unref(getSlotData)(cell) }, () => [Vue.createElementVNode("span", null, Vue.toDisplayString(cell.text), 1)])], 2)], 10, _hoisted_2);
        }), 128))], 2);
      }), 128))])], 2);
    };
  }
});
exports.default = date_table_vue_vue_type_script_setup_true_lang_default;
