import { useId as e } from "react";
import { jsx as t, jsxs as n } from "react/jsx-runtime";
import { getOrCreatePortalRoot as r, useEscapeDismiss as i, useOverlayFocus as a } from "@ryuzaki13/react-foundation-lib/dom";
import { createPortal as o } from "react-dom";
//#region src/dialog/Dialog.tsx
function s({ title: s, description: c, open: l, onClose: u, minWidth: d, children: f }) {
	let p = e(), m = e(), h = a({
		active: l,
		trapFocus: !0,
		restoreFocus: !0,
		initialFocus: "auto"
	});
	if (i({
		active: l,
		onDismiss: u,
		containerRef: h
	}), !l || typeof document > "u") return null;
	let g = r("dialog-root");
	return g ? o(/* @__PURE__ */ t("div", {
		className: "fixed inset0 flexCenter surfaceBackdrop",
		style: { zIndex: "var(--z-dialog)" },
		onMouseDown: (e) => e.target === e.currentTarget && u(),
		children: /* @__PURE__ */ n("div", {
			ref: h,
			role: "dialog",
			"aria-modal": "true",
			"aria-labelledby": s ? p : void 0,
			"aria-describedby": c ? m : void 0,
			tabIndex: -1,
			className: "surface0 shadowMd paddingLg radiusSm",
			style: { minWidth: d },
			children: [
				s && /* @__PURE__ */ t("h2", {
					id: p,
					className: "margin0",
					children: s
				}),
				c && /* @__PURE__ */ t("p", {
					id: m,
					children: c
				}),
				f
			]
		})
	}), g) : null;
}
//#endregion
export { s as Dialog };

//# sourceMappingURL=index.js.map