/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-af8d194 | Cube Dev Team */
import { Children, cloneElement, createContext, useContext, useRef } from "react";
import { jsx } from "react/jsx-runtime";
import { Transition } from "react-transition-group";

//#region src/components/overlays/Modal/OpenTransition.tsx
const OPEN_STATES = {
	entering: false,
	entered: true
};
const OpenTransitionContext = createContext(null);
function useOpenTransitionContext() {
	return useContext(OpenTransitionContext);
}
function OpenTransition(props) {
	const nodeRef = useRef(null);
	return /* @__PURE__ */ jsx(Transition, {
		nodeRef,
		timeout: {
			enter: 0,
			exit: 350
		},
		...props,
		children: (state) => /* @__PURE__ */ jsx("div", {
			ref: nodeRef,
			children: /* @__PURE__ */ jsx(OpenTransitionContext.Provider, {
				value: { transitionState: state },
				children: Children.map(props.children, (child) => child && cloneElement(child, {
					isOpen: !!OPEN_STATES[state],
					transitionState: state
				}))
			})
		})
	});
}

//#endregion
export { OpenTransition, useOpenTransitionContext };
//# sourceMappingURL=OpenTransition.js.map