"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;
