"use client";
const require_get_size = require("../../core/utils/get-size/get-size.cjs");
const require_create_vars_resolver = require("../../core/styles-api/create-vars-resolver/create-vars-resolver.cjs");
const require_use_props = require("../../core/MantineProvider/use-props/use-props.cjs");
const require_use_styles = require("../../core/styles-api/use-styles/use-styles.cjs");
const require_polymorphic_factory = require("../../core/factory/polymorphic-factory.cjs");
const require_Box = require("../../core/Box/Box.cjs");
const require_Image_module = require("./Image.module.cjs");
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
//#region packages/@mantine/core/src/components/Image/Image.tsx
const varsResolver = require_create_vars_resolver.createVarsResolver((_, { radius, fit }) => ({ root: {
	"--image-radius": radius === void 0 ? void 0 : require_get_size.getRadius(radius),
	"--image-object-fit": fit
} }));
const Image = require_polymorphic_factory.polymorphicFactory((_props) => {
	const props = require_use_props.useProps("Image", null, _props);
	const { classNames, className, style, styles, unstyled, vars, onError, src, radius, fit, fallbackSrc, mod, attributes, ...others } = props;
	const [error, setError] = (0, react.useState)(!src);
	(0, react.useEffect)(() => setError(!src), [src]);
	const getStyles = require_use_styles.useStyles({
		name: "Image",
		classes: require_Image_module.default,
		props,
		className,
		style,
		classNames,
		styles,
		unstyled,
		attributes,
		vars,
		varsResolver
	});
	if (error && fallbackSrc) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
		component: "img",
		src: fallbackSrc,
		...getStyles("root"),
		onError,
		mod: ["fallback", mod],
		...others
	});
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
		component: "img",
		...getStyles("root"),
		src,
		onError: (event) => {
			onError?.(event);
			setError(true);
		},
		mod,
		...others
	});
});
Image.classes = require_Image_module.default;
Image.varsResolver = varsResolver;
Image.displayName = "@mantine/core/Image";
//#endregion
exports.Image = Image;

//# sourceMappingURL=Image.cjs.map