"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoggedInHeader = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const box_1 = __importDefault(require("../box"));
const button_1 = __importDefault(require("../button"));
const core_1 = require("../core");
const list_1 = __importDefault(require("../list"));
const utils_1 = require("../utils");
const context_1 = require("./context");
const header_1 = __importDefault(require("./header"));
const headerAccountUserInfo_1 = __importDefault(require("./headerAccountUserInfo"));
const headerServicesMessage_1 = __importDefault(require("./headerServicesMessage"));
/** Displays Header content appropriate for logged-in users, such as services, notifications or account information. */
exports.LoggedInHeader = (0, core_1.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 } = props, rest = __rest(props, ["account", "altUserInfo", "supportLinks", "applicationName", "applicationUrl", "children", "className", "isApplication", "isCleanLayout", "logo", "mainLinks", "services", "showAltUserInfo", "showMainLinks", "showServices", "notifications", "url"]);
    if (isApplication && !applicationName)
        console.error('Header: isApplication is true but applicationName is not set.');
    const userInfo = altUserInfo ? altUserInfo : (0, utils_1.isJsx)(account) ? {} : (account === null || account === void 0 ? void 0 : account.userInfo) || {};
    const isSmallScreen = (0, core_1.useDown)('md');
    const isLessThanMD = (0, core_1.useDown)('sm');
    const servicesLinks = (0, utils_1.isJsx)(services) ? [] : (services === null || services === void 0 ? void 0 : services.links) || [];
    const styles = (0, core_1.useStyleConfig)('Header', (0, context_1.useHeaderContext)());
    const localTextColor = (rest === null || rest === void 0 ? void 0 : rest.variant) === 'dark' ? 'white' : 'darkBlue.main';
    return ((0, jsx_runtime_1.jsx)(header_1.default, Object.assign({ className: (0, utils_1.cs)('vui-loggedInHeader', isApplication ? 'vui-loggedInAppHeader' : undefined, className), mb: isApplication && isSmallScreen ? '41px' : 'inherited', ref: ref }, rest, { children: (0, jsx_runtime_1.jsxs)(header_1.default.Content, { children: [(!isApplication || !isLessThanMD) && (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [" ", (0, utils_1.isJsx)(logo) ? logo : (0, jsx_runtime_1.jsx)(header_1.default.Logo, Object.assign({}, logo))] }), isApplication && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(core_1.RenderOnScreen, { minWidth: "sm", children: (0, jsx_runtime_1.jsx)(header_1.default.Divider, { mr: 2 }) }), (0, jsx_runtime_1.jsx)(header_1.default.ApplicationName, { color: localTextColor, title: applicationName, url: applicationUrl || '/' })] })), !isApplication && (0, jsx_runtime_1.jsx)(core_1.RenderOnScreen, { minWidth: "lg", children: children }), (0, jsx_runtime_1.jsx)(box_1.default, { ml: "auto" }), isCleanLayout ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !!url && ((0, jsx_runtime_1.jsx)(box_1.default, { children: (0, jsx_runtime_1.jsx)(button_1.default, { as: "a", className: (0, utils_1.cs)('vui-headerSignOut'), href: url, size: "lg", variant: "secondaryDark", children: "Sign out" }) })) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isApplication && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(core_1.RenderOnScreen, { minWidth: "lg", children: [showMainLinks && mainLinks !== undefined && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, utils_1.isJsx)(mainLinks) ? mainLinks : (0, jsx_runtime_1.jsx)(header_1.default.MainLinks, { links: mainLinks }), (0, jsx_runtime_1.jsx)(header_1.default.Divider, { mx: 1 })] })), !showMainLinks && mainLinks && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(header_1.default.MobileToggle, { ml: 0 }), (0, jsx_runtime_1.jsx)(header_1.default.MobileContent, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, utils_1.isJsx)(mainLinks) ? (mainLinks) : ((0, jsx_runtime_1.jsx)(box_1.default, { column: true, w: 1, children: (0, jsx_runtime_1.jsx)(list_1.default, { py: 1, children: mainLinks === null || mainLinks === void 0 ? void 0 : mainLinks.map((_a, index) => {
                                                                        var { icon, url } = _a, rest = __rest(_a, ["icon", "url"]);
                                                                        return ((0, jsx_runtime_1.jsx)(list_1.default.Item, Object.assign({ iconLeft: icon, linkProps: { href: url } }, rest), index));
                                                                    }) }) })), !showServices && servicesLinks && ((0, jsx_runtime_1.jsx)(box_1.default, { column: true, w: 1, children: (0, jsx_runtime_1.jsx)(list_1.default, Object.assign({ 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 === null || servicesLinks === void 0 ? void 0 : servicesLinks.map((_a, index) => {
                                                                        var { url } = _a, rest = __rest(_a, ["url"]);
                                                                        return ((0, jsx_runtime_1.jsx)(list_1.default.Item, Object.assign({ linkProps: { href: url } }, rest), index));
                                                                    })) : ((0, jsx_runtime_1.jsx)(headerServicesMessage_1.default, {})) })) }))] }) })] })), showServices && services && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, utils_1.isJsx)(services) ? services : (0, jsx_runtime_1.jsx)(header_1.default.Services, Object.assign({ isApplication: isApplication }, services)) }))] }), (0, jsx_runtime_1.jsx)(header_1.default.Support, Object.assign({}, supportLinks))] })), !isApplication && ((0, jsx_runtime_1.jsxs)(core_1.RenderOnScreen, { minWidth: "lg", children: [(0, utils_1.isJsx)(mainLinks) ? mainLinks : (0, jsx_runtime_1.jsx)(header_1.default.MainLinks, { links: mainLinks }), mainLinks !== undefined && (0, jsx_runtime_1.jsx)(header_1.default.Divider, { mx: 1 }), (0, utils_1.isJsx)(services) ? services : (0, jsx_runtime_1.jsx)(header_1.default.Services, Object.assign({}, services))] })), (0, utils_1.isJsx)(notifications) ? notifications : (0, jsx_runtime_1.jsx)(header_1.default.Notifications, Object.assign({}, notifications)), showAltUserInfo && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(header_1.default.Divider, { ml: 2 }), (0, jsx_runtime_1.jsx)(headerAccountUserInfo_1.default, Object.assign({ className: "vui-altUserInfo", color: localTextColor, isApplication: true }, userInfo))] })), (0, utils_1.isJsx)(account) ? account : (0, jsx_runtime_1.jsx)(header_1.default.Account, Object.assign({}, account)), (0, jsx_runtime_1.jsxs)(core_1.RenderOnScreen, { maxWidth: "lg", children: [isApplication && (0, jsx_runtime_1.jsx)(header_1.default.Divider, { ml: 1 }), !isApplication && (account !== undefined || notifications !== undefined) && (0, jsx_runtime_1.jsx)(header_1.default.Divider, { ml: 1 }), (0, jsx_runtime_1.jsx)(header_1.default.MobileToggle, {}), (0, jsx_runtime_1.jsxs)(header_1.default.MobileContent, { children: [!isApplication && children, (0, utils_1.isJsx)(mainLinks) ? mainLinks : (0, jsx_runtime_1.jsx)(header_1.default.MainLinks, { links: mainLinks }), (0, utils_1.isJsx)(services) ? (services) : ((0, jsx_runtime_1.jsx)(header_1.default.Services, Object.assign({}, services, { showTopBorder: mainLinks ? true : false })))] })] })] }))] }) })));
});
exports.LoggedInHeader.displayName = 'LoggedInHeader';
exports.default = exports.LoggedInHeader;
//# sourceMappingURL=loggedInHeader.js.map