import { afterAll as e, afterEach as t } from "../node_modules/@vitest/runner/dist/chunk-artifact.js";
import { act as n } from "react";
import { createRoot as r } from "react-dom/client";
//#region src/__tests__/reactDomTestUtils.tsx
var i = /* @__PURE__ */ new Map(), a, o = !1, s = async () => {
	let e = [...i.keys()];
	for (let t of e) await n(async () => {
		t.unmount();
	}), i.get(t)?.remove(), i.delete(t);
	document.body.innerHTML = "";
}, c = () => {
	o || (o = !0, a = Object.getOwnPropertyDescriptor(globalThis, "IS_REACT_ACT_ENVIRONMENT"), Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", {
		value: !0,
		configurable: !0
	}), t(async () => {
		await s();
	}), e(() => {
		if (a == null) {
			Reflect.deleteProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT");
			return;
		}
		Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", a);
	}));
}, l = async (e, t) => {
	let a = t?.container ?? document.createElement("div");
	document.body.contains(a) || document.body.append(a);
	let o = r(a);
	i.set(o, a);
	let s = async (e) => {
		await n(async () => {
			o.render(e);
		});
	};
	return await s(e), {
		container: a,
		root: o,
		rerender: s,
		unmount: async () => {
			i.has(o) && (await n(async () => {
				o.unmount();
			}), a.remove(), i.delete(o));
		}
	};
};
//#endregion
export { n as act, s as cleanupReactDomTests, l as renderReactDom, c as setupReactDomTests };

//# sourceMappingURL=reactDomTestUtils.js.map