import { createVNode as _createVNode, isVNode as _isVNode, mergeProps as _mergeProps } from "vue";
import { computed } from "vue";
import { defineComponent } from "../../utils";
import { SelectionControl } from "../selection-control";
import { useProxiedModel } from "../../composables/proxied-model";
import { filterSelectionControlProps, makeSelectionControlProps } from "../selection-control/selection-control";
function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !_isVNode(s);
}
const Checkbox = defineComponent({
  name: "VeCheckbox",
  props: {
    /**
     * @zh 不确定的
     */
    indeterminate: Boolean,
    /**
     * @zh 不确定的图标
     */
    indeterminateIcon: {
      type: String,
      default: "$checkboxIndeterminate"
    },
    ...makeSelectionControlProps({
      type: "checkbox",
      falseIcon: "$checkboxOff",
      trueIcon: "$checkboxOn",
      color: "primary"
    })
  },
  emits: {
    "update:modelValue": (_val) => true,
    "update:indeterminate": (_val) => true
  },
  setup(props, {
    emit,
    slots
  }) {
    const indeterminate = useProxiedModel(props, "indeterminate");
    const falseIcon = computed(() => {
      return indeterminate.value ? props.indeterminateIcon : props.falseIcon;
    });
    const trueIcon = computed(() => {
      return indeterminate.value ? props.indeterminateIcon : props.trueIcon;
    });
    function onChange(val) {
      if (indeterminate.value) {
        indeterminate.value = false;
      } else {
        emit("update:modelValue", val);
      }
    }
    return () => {
      const [controlProps] = filterSelectionControlProps(props);
      return _createVNode(SelectionControl, _mergeProps(controlProps, {
        "class": "ve-checkbox",
        "onUpdate:modelValue": onChange,
        "falseIcon": falseIcon.value,
        "trueIcon": trueIcon.value,
        "aria-checked": indeterminate.value ? "mixed" : void 0
      }), _isSlot(slots) ? slots : {
        default: () => [slots]
      });
    };
  }
});
export {
  Checkbox
};
//# sourceMappingURL=checkbox.mjs.map
