import { defineComponent, computed, watch } from 'vue';
import { Select, Checkbox, CheckboxGroup, Radio, RadioGroup, InputNumber } from 'ant-design-vue';
import { useTabSetup, TypeEnum, useTabEmits, useTabProps } from '../../config/use-tab-mixin.mjs';

"use strict";
const WEEK_MAP_EN = {
  "1": "SUN",
  "2": "MON",
  "3": "TUE",
  "4": "WED",
  "5": "THU",
  "6": "FRI",
  "7": "SAT"
};
const WEEK_MAP_CN = {
  "1": "\u5468\u65E5",
  "2": "\u5468\u4E00",
  "3": "\u5468\u4E8C",
  "4": "\u5468\u4E09",
  "5": "\u5468\u56DB",
  "6": "\u5468\u4E94",
  "7": "\u5468\u516D"
};
var _sfc_main = defineComponent({
  name: "WeekUI",
  components: {
    InputNumber,
    RadioGroup,
    Radio,
    CheckboxGroup,
    Checkbox,
    ASelect: Select
  },
  props: {
    ...useTabProps({
      defaultValue: "?"
    }),
    day: {
      type: String,
      default: "*"
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  emits: useTabEmits(),
  setup(props, context) {
    const disabledChoice = computed(() => {
      return props.day && props.day !== "?" || props.disabled;
    });
    const setup = useTabSetup(props, context, {
      defaultType: TypeEnum.unset,
      defaultValue: "?",
      minValue: 1,
      maxValue: 7,
      // 0,7表示周日 1表示周一
      valueRange: { start: 1, end: 7 },
      valueLoop: { start: 2, interval: 1 },
      disabled: disabledChoice
    });
    const weekOptions = computed(() => {
      const options = [];
      for (const weekKey of Object.keys(WEEK_MAP_CN)) {
        const weekName = WEEK_MAP_CN[weekKey];
        options.push({
          value: Number.parseInt(weekKey),
          label: weekName
        });
      }
      return options;
    });
    const typeRangeSelectAttrs = computed(() => ({
      class: ["w100"],
      disabled: setup.typeRangeAttrs.value.disabled
    }));
    const typeLoopSelectAttrs = computed(() => ({
      class: ["w100"],
      disabled: setup.typeLoopAttrs.value.disabled
    }));
    watch(
      () => props.day,
      () => {
        setup.updateValue(disabledChoice.value ? "?" : setup.computeValue.value);
      }
    );
    return {
      ...setup,
      weekOptions,
      typeLoopSelectAttrs,
      typeRangeSelectAttrs,
      WEEK_MAP_CN,
      WEEK_MAP_EN
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=week-ui.vue2.mjs.map
