import { isJsx, isReactText, isString } from "../utils/assertion.js";
import { cs } from "../utils/styles.js";
import { useStyleConfig } from "../core/theme.js";
import vui from "../core/vui.js";
import Box from "../box/box.js";
import { useDialogContext } from "./context.js";
import DialogCloseButton from "./dialogCloseButton.js";
import DialogIcon from "./dialogIcon.js";
import DialogTitle from "./dialogTitle.js";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";

//#region src/dialog/dialogHeader.tsx
/** Shows title, status icon and close button above the Dialog Body. */
const DialogHeader = vui((props, ref) => {
	const { children, className, closeButton, icon: iconProp, title: titleProp, ...rest } = props;
	const { onClose, status } = useDialogContext() ?? {};
	const styles = useStyleConfig("Dialog", useDialogContext());
	const icon = isString(iconProp) ? { name: iconProp } : iconProp;
	const showCloseButton = Boolean(closeButton !== void 0 ? closeButton : onClose);
	const showIcon = Boolean(icon || status);
	const title = isReactText(titleProp) ? { text: titleProp } : titleProp;
	return /* @__PURE__ */ jsx(Box, {
		className: cs("vui-dialogHeader", className),
		icon,
		pb: 1.5,
		pl: 3,
		position: "relative",
		pr: 8,
		pt: 3,
		ref,
		...styles.header,
		...rest,
		children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
			isJsx(icon) ? icon : showIcon && /* @__PURE__ */ jsx(DialogIcon, { ...icon }),
			isJsx(title) ? title : !!title && /* @__PURE__ */ jsx(DialogTitle, { ...title }),
			isJsx(closeButton) ? closeButton : showCloseButton && /* @__PURE__ */ jsx(DialogCloseButton, {})
		] })
	});
});
DialogHeader.displayName = "DialogHeader";

//#endregion
export { DialogHeader as default };
globalThis.__vuiVersion__ = "4.0.0"
//# sourceMappingURL=dialogHeader.js.map