"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 Box = require("../../core/Box/Box.cjs");
const polymorphicFactory = require("../../core/factory/polymorphic-factory.cjs");
const ColorSwatch_module_css = require("./ColorSwatch.module.css.cjs");
const defaultProps = {
  withShadow: true
};
const varsResolver = createVarsResolver.createVarsResolver((_, { radius, size }) => ({
  root: {
    "--cs-radius": radius === void 0 ? void 0 : getSize.getRadius(radius),
    "--cs-size": rem.rem(size)
  }
}));
const ColorSwatch = polymorphicFactory.polymorphicFactory((_props, ref) => {
  const props = useProps.useProps("ColorSwatch", defaultProps, _props);
  const {
    classNames,
    className,
    style,
    styles,
    unstyled,
    vars,
    color,
    size,
    radius,
    withShadow,
    children,
    variant,
    ...others
  } = useProps.useProps("ColorSwatch", defaultProps, props);
  const getStyles = useStyles.useStyles({
    name: "ColorSwatch",
    props,
    classes: ColorSwatch_module_css.default,
    className,
    style,
    classNames,
    styles,
    unstyled,
    vars,
    varsResolver
  });
  return /* @__PURE__ */ jsxRuntime.jsxs(
    Box.Box,
    {
      ref,
      variant,
      size,
      ...getStyles("root", { focusable: true }),
      ...others,
      children: [
        /* @__PURE__ */ jsxRuntime.jsx("span", { ...getStyles("alphaOverlay") }),
        withShadow && /* @__PURE__ */ jsxRuntime.jsx("span", { ...getStyles("shadowOverlay") }),
        /* @__PURE__ */ jsxRuntime.jsx("span", { ...getStyles("colorOverlay", { style: { backgroundColor: color } }) }),
        /* @__PURE__ */ jsxRuntime.jsx("span", { ...getStyles("childrenOverlay"), children })
      ]
    }
  );
});
ColorSwatch.classes = ColorSwatch_module_css.default;
ColorSwatch.displayName = "@mantine/core/ColorSwatch";
exports.ColorSwatch = ColorSwatch;
