import { isJsx } from "../utils/assertion.js";
import { cs } from "../utils/styles.js";
import "../utils/index.js";
import { useStyleConfig } from "../core/theme.js";
import { RenderOnScreen, useDown } from "../core/media.js";
import { vui } from "../core/vui.js";
import box_default from "../box/box.js";
import "../box/index.js";
import button_default from "../button/button.js";
import "../button/index.js";
import "../core/index.js";
import list_default from "../list/list.js";
import "../list/index.js";
import { useHeaderContext } from "./context.js";
import headerAccountUserInfo_default from "./headerAccountUserInfo.js";
import headerServicesMessage_default from "./headerServicesMessage.js";
import header_default from "./header.js";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";

//#region src/header/loggedInHeader.tsx
/** Displays Header content appropriate for logged-in users, such as services, notifications or account information. */
const LoggedInHeader = vui((props, ref) => {
	const { account, altUserInfo, supportLinks, applicationName, applicationUrl, children, className, isApplication = false, isCleanLayout = false, logo, mainLinks, services, showAltUserInfo = false, showMainLinks = isApplication ? false : true, showServices = true, notifications, url, ...rest } = props;
	if (isApplication && !applicationName) console.error("Header: isApplication is true but applicationName is not set.");
	const userInfo = altUserInfo ? altUserInfo : isJsx(account) ? {} : account?.userInfo || {};
	const isSmallScreen = useDown("md");
	const isLessThanMD = useDown("sm");
	const servicesLinks = isJsx(services) ? [] : services?.links || [];
	const styles = useStyleConfig("Header", useHeaderContext());
	const localTextColor = rest?.variant === "dark" ? "white" : "darkBlue.main";
	return /* @__PURE__ */ jsx(header_default, {
		className: cs("vui-loggedInHeader", isApplication ? "vui-loggedInAppHeader" : void 0, className),
		mb: isApplication && isSmallScreen ? "41px" : "inherited",
		ref,
		...rest,
		children: /* @__PURE__ */ jsxs(header_default.Content, { children: [
			(!isApplication || !isLessThanMD) && /* @__PURE__ */ jsxs(Fragment, { children: [" ", isJsx(logo) ? logo : /* @__PURE__ */ jsx(header_default.Logo, { ...logo })] }),
			isApplication && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(RenderOnScreen, {
				minWidth: "sm",
				children: /* @__PURE__ */ jsx(header_default.Divider, { mr: 2 })
			}), /* @__PURE__ */ jsx(header_default.ApplicationName, {
				color: localTextColor,
				title: applicationName,
				url: applicationUrl
			})] }),
			!isApplication && /* @__PURE__ */ jsx(RenderOnScreen, {
				minWidth: "lg",
				children
			}),
			/* @__PURE__ */ jsx(box_default, { ml: "auto" }),
			isCleanLayout ? /* @__PURE__ */ jsx(Fragment, { children: !!url && /* @__PURE__ */ jsx(box_default, { children: /* @__PURE__ */ jsx(button_default, {
				as: "a",
				className: cs("vui-headerSignOut"),
				href: url,
				size: "lg",
				variant: "secondaryDark",
				children: "Sign out"
			}) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
				isApplication && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(RenderOnScreen, {
					minWidth: "lg",
					children: [
						showMainLinks && mainLinks !== void 0 && /* @__PURE__ */ jsxs(Fragment, { children: [isJsx(mainLinks) ? mainLinks : /* @__PURE__ */ jsx(header_default.MainLinks, { links: mainLinks }), /* @__PURE__ */ jsx(header_default.Divider, { mx: 1 })] }),
						!showMainLinks && mainLinks && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(header_default.MobileToggle, { ml: 0 }), /* @__PURE__ */ jsx(header_default.MobileContent, { children: /* @__PURE__ */ jsxs(Fragment, { children: [isJsx(mainLinks) ? mainLinks : /* @__PURE__ */ jsx(box_default, {
							column: true,
							w: 1,
							children: /* @__PURE__ */ jsx(list_default, {
								py: 1,
								children: mainLinks?.map(({ icon, url: url$1, ...rest$1 }, index) => /* @__PURE__ */ jsx(list_default.Item, {
									iconLeft: icon,
									linkProps: { href: url$1 },
									...rest$1
								}, index))
							})
						}), !showServices && servicesLinks && /* @__PURE__ */ jsx(box_default, {
							column: true,
							w: 1,
							children: /* @__PURE__ */ jsx(list_default, {
								className: "vui-headerHiddenServicesLargeScreen",
								heading: "My Services",
								maxH: 295,
								right: 0,
								w: 320,
								...styles.services.list,
								borderTop: 1,
								borderTopColor: "sandstone.main",
								pt: 1,
								children: servicesLinks.length > 0 ? servicesLinks?.map(({ url: url$1, ...rest$1 }, index) => /* @__PURE__ */ jsx(list_default.Item, {
									linkProps: { href: url$1 },
									...rest$1
								}, index)) : /* @__PURE__ */ jsx(headerServicesMessage_default, {})
							})
						})] }) })] }),
						showServices && services && /* @__PURE__ */ jsx(Fragment, { children: isJsx(services) ? services : /* @__PURE__ */ jsx(header_default.Services, {
							isApplication,
							...services
						}) })
					]
				}), /* @__PURE__ */ jsx(header_default.Support, { ...supportLinks })] }),
				!isApplication && /* @__PURE__ */ jsxs(RenderOnScreen, {
					minWidth: "lg",
					children: [
						isJsx(mainLinks) ? mainLinks : /* @__PURE__ */ jsx(header_default.MainLinks, { links: mainLinks }),
						mainLinks !== void 0 && /* @__PURE__ */ jsx(header_default.Divider, { mx: 1 }),
						isJsx(services) ? services : /* @__PURE__ */ jsx(header_default.Services, { ...services })
					]
				}),
				isJsx(notifications) ? notifications : /* @__PURE__ */ jsx(header_default.Notifications, { ...notifications }),
				showAltUserInfo && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(header_default.Divider, { ml: 2 }), /* @__PURE__ */ jsx(headerAccountUserInfo_default, {
					className: "vui-altUserInfo",
					color: localTextColor,
					isApplication: true,
					...userInfo
				})] }),
				isJsx(account) ? account : /* @__PURE__ */ jsx(header_default.Account, { ...account }),
				/* @__PURE__ */ jsxs(RenderOnScreen, {
					maxWidth: "lg",
					children: [
						isApplication && /* @__PURE__ */ jsx(header_default.Divider, { ml: 1 }),
						!isApplication && (account !== void 0 || notifications !== void 0) && /* @__PURE__ */ jsx(header_default.Divider, { ml: 1 }),
						/* @__PURE__ */ jsx(header_default.MobileToggle, {}),
						/* @__PURE__ */ jsxs(header_default.MobileContent, { children: [
							!isApplication && children,
							isJsx(mainLinks) ? mainLinks : /* @__PURE__ */ jsx(header_default.MainLinks, { links: mainLinks }),
							isJsx(services) ? services : /* @__PURE__ */ jsx(header_default.Services, {
								...services,
								showTopBorder: mainLinks ? true : false
							})
						] })
					]
				})
			] })
		] })
	});
});
LoggedInHeader.displayName = "LoggedInHeader";

//#endregion
export { LoggedInHeader };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=loggedInHeader.js.map