import { Children as e, useEffect as t, useState as n } from "react";
import { jsx as r } from "react/jsx-runtime";
import { createPortal as i } from "react-dom";
//#region lib/ui/Portal.tsx
var a = (e) => {
	/* c8 ignore next 4 */
	if (typeof document > "u") return console.warn("createDivElementWithId() can not be run outside of a browser"), null;
	let t = document.createElement("div");
	return t.id = e, t.classList.add("relative", "isolate", "z-1"), document.body.append(t), t;
};
function o({ children: r, target: o = "portal", disabled: s = !1, key: c }) {
	let [l, u] = n(!1), [d, f] = n(null);
	return t(() => {
		if (u(!0), d === null) {
			let e = document.getElementById(o) || a(o);
			e && f(e);
		}
	}, [o]), l ? s ? r : e.count(r) && d ? i(r, d, c) : null : null;
}
function s(e, t) {
	return (n) => /* @__PURE__ */ r(o, {
		target: e,
		children: /* @__PURE__ */ r(t, { ...n })
	});
}
//#endregion
export { o as Portal, s as withPortal };

//# sourceMappingURL=Portal.js.map