"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
require("react");
const getSize = require("../../../core/utils/get-size/get-size.cjs");
const createVarsResolver = require("../../../core/styles-api/create-vars-resolver/create-vars-resolver.cjs");
require("clsx");
const parseThemeColor = require("../../../core/MantineProvider/color-functions/parse-theme-color/parse-theme-color.cjs");
const getThemeColor = require("../../../core/MantineProvider/color-functions/get-theme-color/get-theme-color.cjs");
const getContrastColor = require("../../../core/MantineProvider/color-functions/get-contrast-color/get-contrast-color.cjs");
const getAutoContrastValue = require("../../../core/MantineProvider/color-functions/get-auto-contrast-value/get-auto-contrast-value.cjs");
const useProps = require("../../../core/MantineProvider/use-props/use-props.cjs");
const useStyles = require("../../../core/styles-api/use-styles/use-styles.cjs");
const Box = require("../../../core/Box/Box.cjs");
const factory = require("../../../core/factory/factory.cjs");
const CheckboxCard_context = require("../CheckboxCard/CheckboxCard.context.cjs");
const CheckIcon = require("../CheckIcon.cjs");
const CheckboxIndicator_module_css = require("./CheckboxIndicator.module.css.cjs");
const defaultProps = {
  icon: CheckIcon.CheckboxIcon
};
const varsResolver = createVarsResolver.createVarsResolver(
  (theme, { radius, color, size, iconColor, variant, autoContrast }) => {
    const parsedColor = parseThemeColor.parseThemeColor({ color: color || theme.primaryColor, theme });
    const outlineColor = parsedColor.isThemeColor && parsedColor.shade === void 0 ? `var(--mantine-color-${parsedColor.color}-outline)` : parsedColor.color;
    return {
      indicator: {
        "--checkbox-size": getSize.getSize(size, "checkbox-size"),
        "--checkbox-radius": radius === void 0 ? void 0 : getSize.getRadius(radius),
        "--checkbox-color": variant === "outline" ? outlineColor : getThemeColor.getThemeColor(color, theme),
        "--checkbox-icon-color": iconColor ? getThemeColor.getThemeColor(iconColor, theme) : getAutoContrastValue.getAutoContrastValue(autoContrast, theme) ? getContrastColor.getContrastColor({ color, theme, autoContrast }) : void 0
      }
    };
  }
);
const CheckboxIndicator = factory.factory((_props, ref) => {
  const props = useProps.useProps("CheckboxIndicator", defaultProps, _props);
  const {
    classNames,
    className,
    style,
    styles,
    unstyled,
    vars,
    icon,
    indeterminate,
    radius,
    color,
    iconColor,
    autoContrast,
    checked,
    mod,
    variant,
    disabled,
    ...others
  } = props;
  const Icon = icon;
  const getStyles = useStyles.useStyles({
    name: "CheckboxIndicator",
    classes: CheckboxIndicator_module_css.default,
    props,
    className,
    style,
    classNames,
    styles,
    unstyled,
    vars,
    varsResolver,
    rootSelector: "indicator"
  });
  const ctx = CheckboxCard_context.useCheckboxCardContext();
  const _checked = typeof checked === "boolean" || typeof indeterminate === "boolean" ? checked || indeterminate : (ctx == null ? void 0 : ctx.checked) || false;
  return /* @__PURE__ */ jsxRuntime.jsx(
    Box.Box,
    {
      ref,
      ...getStyles("indicator", { variant }),
      variant,
      mod: [{ checked: _checked, disabled }, mod],
      ...others,
      children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { indeterminate, ...getStyles("icon") })
    }
  );
});
CheckboxIndicator.displayName = "@mantine/core/CheckboxIndicator";
CheckboxIndicator.classes = CheckboxIndicator_module_css.default;
exports.CheckboxIndicator = CheckboxIndicator;
