"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const rem = require("../../core/utils/units-converters/rem.cjs");
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 useProps = require("../../core/MantineProvider/use-props/use-props.cjs");
const useStyles = require("../../core/styles-api/use-styles/use-styles.cjs");
const polymorphicFactory = require("../../core/factory/polymorphic-factory.cjs");
const UnstyledButton = require("../UnstyledButton/UnstyledButton.cjs");
const CloseIcon = require("./CloseIcon.cjs");
const CloseButton_module_css = require("./CloseButton.module.css.cjs");
const defaultProps = {
  variant: "subtle"
};
const varsResolver = createVarsResolver.createVarsResolver((_, { size, radius, iconSize }) => ({
  root: {
    "--cb-size": getSize.getSize(size, "cb-size"),
    "--cb-radius": radius === void 0 ? void 0 : getSize.getRadius(radius),
    "--cb-icon-size": rem.rem(iconSize)
  }
}));
const CloseButton = polymorphicFactory.polymorphicFactory((_props, ref) => {
  const props = useProps.useProps("CloseButton", defaultProps, _props);
  const {
    iconSize,
    children,
    vars,
    radius,
    className,
    classNames,
    style,
    styles,
    unstyled,
    "data-disabled": dataDisabled,
    disabled,
    variant,
    icon,
    mod,
    ...others
  } = props;
  const getStyles = useStyles.useStyles({
    name: "CloseButton",
    props,
    className,
    style,
    classes: CloseButton_module_css.default,
    classNames,
    styles,
    unstyled,
    vars,
    varsResolver
  });
  return /* @__PURE__ */ jsxRuntime.jsxs(
    UnstyledButton.UnstyledButton,
    {
      ref,
      ...others,
      unstyled,
      variant,
      disabled,
      mod: [{ disabled: disabled || dataDisabled }, mod],
      ...getStyles("root", { variant, active: !disabled && !dataDisabled }),
      children: [
        icon || /* @__PURE__ */ jsxRuntime.jsx(CloseIcon.CloseIcon, {}),
        children
      ]
    }
  );
});
CloseButton.classes = CloseButton_module_css.default;
CloseButton.displayName = "@mantine/core/CloseButton";
exports.CloseButton = CloseButton;
