"use client";
const require_get_default_z_index = require("../../core/utils/get-default-z-index/get-default-z-index.cjs");
const require_get_size = require("../../core/utils/get-size/get-size.cjs");
const require_Box = require("../../core/Box/Box.cjs");
const require_OptionalPortal = require("../Portal/OptionalPortal.cjs");
const require_ModalBase_context = require("./ModalBase.context.cjs");
const require_use_modal = require("./use-modal.cjs");
let react_remove_scroll = require("react-remove-scroll");
let react_jsx_runtime = require("react/jsx-runtime");
//#region packages/@mantine/core/src/components/ModalBase/ModalBase.tsx
function ModalBase({ keepMounted, opened, onClose, id, transitionProps, onExitTransitionEnd, onEnterTransitionEnd, trapFocus, closeOnEscape, returnFocus, closeOnClickOutside, withinPortal, portalProps, lockScroll, children, zIndex, shadow, padding, __vars, unstyled, removeScrollProps, ...others }) {
	const { _id, titleMounted, bodyMounted, shouldLockScroll, setTitleMounted, setBodyMounted } = require_use_modal.useModal({
		id,
		transitionProps,
		opened,
		trapFocus,
		closeOnEscape,
		onClose,
		returnFocus
	});
	const { key: removeScrollKey, ...otherRemoveScrollProps } = removeScrollProps || {};
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_OptionalPortal.OptionalPortal, {
		...portalProps,
		withinPortal,
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ModalBase_context.ModalBaseProvider, {
			value: {
				opened,
				onClose,
				closeOnClickOutside,
				onExitTransitionEnd,
				onEnterTransitionEnd,
				transitionProps: {
					...transitionProps,
					keepMounted
				},
				getTitleId: () => `${_id}-title`,
				getBodyId: () => `${_id}-body`,
				titleMounted,
				bodyMounted,
				setTitleMounted,
				setBodyMounted,
				trapFocus,
				closeOnEscape,
				zIndex,
				unstyled
			},
			children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_remove_scroll.RemoveScroll, {
				enabled: shouldLockScroll && lockScroll,
				...otherRemoveScrollProps,
				children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
					...others,
					id: _id,
					__vars: {
						...__vars,
						"--mb-z-index": (zIndex || require_get_default_z_index.getDefaultZIndex("modal")).toString(),
						"--mb-shadow": require_get_size.getShadow(shadow),
						"--mb-padding": require_get_size.getSpacing(padding)
					},
					children
				})
			}, removeScrollKey)
		})
	});
}
ModalBase.displayName = "@mantine/core/ModalBase";
//#endregion
exports.ModalBase = ModalBase;

//# sourceMappingURL=ModalBase.cjs.map