import { isUndefined } from "../../../../utils/types.mjs";
import { formContextKey } from "../../../form/src/constants.mjs";
import { useFormDisabled } from "../../../form/src/hooks/use-form-common-props.mjs";
import { checkboxGroupContextKey } from "../constants.mjs";
import { inject, computed } from "vue";
const useCheckboxDisabled = ({ model, isChecked }) => {
  const checkboxGroup = inject(checkboxGroupContextKey, void 0);
  const formContext = inject(formContextKey, void 0);
  const isLimitDisabled = computed(() => {
    var _a, _b;
    const max = (_a = checkboxGroup == null ? void 0 : checkboxGroup.max) == null ? void 0 : _a.value;
    const min = (_b = checkboxGroup == null ? void 0 : checkboxGroup.min) == null ? void 0 : _b.value;
    return !isUndefined(max) && model.value.length >= max && !isChecked.value || !isUndefined(min) && model.value.length <= min && isChecked.value;
  });
  return {
    isDisabled: useFormDisabled(computed(() => {
      var _a;
      if (checkboxGroup === void 0) return (formContext == null ? void 0 : formContext.disabled) ?? isLimitDisabled.value;
      else return ((_a = checkboxGroup.disabled) == null ? void 0 : _a.value) || isLimitDisabled.value;
    })),
    isLimitDisabled
  };
};
export {
  useCheckboxDisabled
};
