"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const types = require("../../../../utils/types.js");
const useFormCommonProps = require("../../../form/src/hooks/use-form-common-props.js");
const constants = require("../constants.js");
const vue = require("vue");
const shared_esmBundler = require("../../../../../../@vue/shared/dist/shared.esm-bundler.js");
const isEqual = require("../../../../../../lodash-es/isEqual.js");
const useCheckboxStatus = (props, slots, { model }) => {
  const checkboxGroup = vue.inject(constants.checkboxGroupContextKey, void 0);
  const isFocused = vue.ref(false);
  const actualValue = vue.computed(() => {
    if (!types.isPropAbsent(props.value)) return props.value;
    return props.label;
  });
  const isChecked = vue.computed(() => {
    const value = model.value;
    if (types.isBoolean(value)) return value;
    else if (shared_esmBundler.isArray(value)) if (shared_esmBundler.isObject(actualValue.value)) return value.map(vue.toRaw).some((o) => isEqual.default(o, actualValue.value));
    else return value.map(vue.toRaw).includes(actualValue.value);
    else if (value !== null && value !== void 0) return value === props.trueValue || value === props.trueLabel;
    else return !!value;
  });
  return {
    checkboxButtonSize: useFormCommonProps.useFormSize(vue.computed(() => {
      var _a;
      return (_a = checkboxGroup == null ? void 0 : checkboxGroup.size) == null ? void 0 : _a.value;
    }), { prop: true }),
    isChecked,
    isFocused,
    checkboxSize: useFormCommonProps.useFormSize(vue.computed(() => {
      var _a;
      return (_a = checkboxGroup == null ? void 0 : checkboxGroup.size) == null ? void 0 : _a.value;
    })),
    hasOwnLabel: vue.computed(() => {
      return !!slots.default || !types.isPropAbsent(actualValue.value);
    }),
    actualValue
  };
};
exports.useCheckboxStatus = useCheckboxStatus;
