"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const utils = require("./utils.js");
const props = require("../utils/props.js");
const create = require("../utils/create.js");
const [name] = create.createNamespace("calendar-day");
var stdin_default = Vue.defineComponent({
  name,
  props: {
    item: props.makeRequiredProp(Object),
    color: String,
    index: Number,
    offset: props.makeNumberProp(0),
    rowHeight: String
  },
  emits: ["click", "clickDisabledDate"],
  setup(props2, {
    emit,
    slots
  }) {
    const style = Vue.computed(() => {
      const {
        item,
        index,
        color,
        offset,
        rowHeight
      } = props2;
      const style2 = {
        height: rowHeight
      };
      if (item.type === "placeholder") {
        style2.width = "100%";
        return style2;
      }
      if (index === 0) {
        style2.marginLeft = `${100 * offset / 7}%`;
      }
      if (color) {
        switch (item.type) {
          case "end":
          case "start":
          case "start-end":
          case "multiple-middle":
          case "multiple-selected":
            style2.background = color;
            break;
          case "middle":
            style2.color = color;
            break;
        }
      }
      if (item.date && utils.isLastRowInMonth(item.date, offset)) {
        style2.marginBottom = 0;
      }
      return style2;
    });
    const onClick = () => {
      if (props2.item.type !== "disabled") {
        emit("click", props2.item);
      } else {
        emit("clickDisabledDate", props2.item);
      }
    };
    const renderTopInfo = () => {
      const {
        topInfo
      } = props2.item;
      if (topInfo || slots["top-info"]) {
        return Vue.createVNode("div", {
          "class": utils.bem("top-info")
        }, [slots["top-info"] ? slots["top-info"](props2.item) : topInfo]);
      }
    };
    const renderBottomInfo = () => {
      const {
        bottomInfo
      } = props2.item;
      if (bottomInfo || slots["bottom-info"]) {
        return Vue.createVNode("div", {
          "class": utils.bem("bottom-info")
        }, [slots["bottom-info"] ? slots["bottom-info"](props2.item) : bottomInfo]);
      }
    };
    const renderText = () => {
      return slots.text ? slots.text(props2.item) : props2.item.text;
    };
    const renderContent = () => {
      const {
        item,
        color,
        rowHeight
      } = props2;
      const {
        type
      } = item;
      const Nodes = [renderTopInfo(), renderText(), renderBottomInfo()];
      if (type === "selected") {
        return Vue.createVNode("div", {
          "class": utils.bem("selected-day"),
          "style": {
            width: rowHeight,
            height: rowHeight,
            background: color
          }
        }, [Nodes]);
      }
      return Nodes;
    };
    return () => {
      const {
        type,
        className
      } = props2.item;
      if (type === "placeholder") {
        return Vue.createVNode("div", {
          "class": utils.bem("day"),
          "style": style.value
        }, null);
      }
      return Vue.createVNode("div", {
        "role": "gridcell",
        "style": style.value,
        "class": [utils.bem("day", type), className],
        "tabindex": type === "disabled" ? void 0 : -1,
        "onClick": onClick
      }, [renderContent()]);
    };
  }
});
exports.default = stdin_default;
