import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot, createTextVNode, toDisplayString, createCommentVNode } from 'vue';
import getPrefixCls from '../_util/getPrefixCls';
import useSelect from '../_util/use/useSelect';
import { checkboxGroupKey, COMPONENT_NAME } from '../checkbox-group/const';
import { useTheme } from '../_theme/useTheme';
import { UPDATE_MODEL_EVENT, CHANGE_EVENT } from '../_util/constants';
import { checkboxProps } from './props';

const prefixCls = getPrefixCls('checkbox');
var script = defineComponent({
  name: 'FCheckbox',
  props: checkboxProps,
  emits: [UPDATE_MODEL_EVENT, CHANGE_EVENT],
  setup(props, _ref) {
    let {
      emit
    } = _ref;
    useTheme();
    const {
      isGroup,
      group,
      hover,
      checked,
      innerDisabled,
      handleClick,
      handleMouseOver,
      handleMouseOut
    } = useSelect({
      props,
      emit,
      parent: {
        groupKey: checkboxGroupKey,
        name: COMPONENT_NAME
      }
    });
    const wrapperClass = computed(() => {
      const arr = [`${prefixCls}`];
      if (checked.value) {
        arr.push('is-checked');
      }
      if (innerDisabled.value) {
        arr.push('is-disabled');
      }
      if (hover.value) {
        arr.push('is-hover');
      }
      if (isGroup) {
        var _group$props;
        arr.push('is-item');
        if (group !== null && group !== void 0 && (_group$props = group.props) !== null && _group$props !== void 0 && _group$props.vertical) {
          arr.push('is-item-vertical');
        }
      }
      if (props.indeterminate) {
        arr.push('is-indeterminate');
      }
      return arr;
    });
    return {
      prefixCls,
      wrapperClass,
      handleClick,
      handleMouseOver,
      handleMouseOut
    };
  }
});

function render(_ctx, _cache, $props, $setup, $data, $options) {
  return openBlock(), createElementBlock("label", {
    class: normalizeClass(_ctx.wrapperClass),
    onClick: _cache[0] || (_cache[0] = function () {
      return _ctx.handleClick && _ctx.handleClick(...arguments);
    }),
    onMouseover: _cache[1] || (_cache[1] = function () {
      return _ctx.handleMouseOver && _ctx.handleMouseOver(...arguments);
    }),
    onMouseout: _cache[2] || (_cache[2] = function () {
      return _ctx.handleMouseOut && _ctx.handleMouseOut(...arguments);
    })
  }, [createElementVNode("span", {
    class: normalizeClass(`${_ctx.prefixCls}-inner`)
  }, null, 2 /* CLASS */), _ctx.$slots.default || _ctx.label ? (openBlock(), createElementBlock("span", {
    key: 0,
    class: normalizeClass(`${_ctx.prefixCls}-content`)
  }, [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(_ctx.label), 1 /* TEXT */)])], 2 /* CLASS */)) : createCommentVNode("v-if", true)], 34 /* CLASS, NEED_HYDRATION */);
}

script.render = render;
script.__file = "components/checkbox/checkbox.vue";

export { script as default };
