"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.Footer = exports.FooterBase = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const box_1 = require("../box");
const core_1 = require("../core");
const divider_1 = require("../divider");
const link_1 = require("../link");
const menu_1 = __importDefault(require("../menu"));
const t_1 = require("../t");
const utils_1 = require("../utils");
const context_1 = require("./context");
const footerColumn_1 = __importDefault(require("./footerColumn"));
const footerContent_1 = __importDefault(require("./footerContent"));
const footerHeading_1 = __importDefault(require("./footerHeading"));
const footerLink_1 = __importDefault(require("./footerLink"));
const footerRow_1 = __importDefault(require("./footerRow"));
const footerSection_1 = __importDefault(require("./footerSection"));
const footerSlimColumn_1 = __importDefault(require("./footerSlimColumn"));
const footerTrademark_1 = require("./footerTrademark");
/*@formatter:off*/
exports.FooterBase = core_1.styled.divBox `
  background-color: darkBlue.main;
  color: white;
  padding: 5 3;
`;
/*@formatter:on*/
const currentYear = (0, utils_1.getCurrentYear)();
/** Branded Veracity Footer with trademark and links sections. Controls max-width of the content. */
exports.Footer = (0, core_1.vui)((props, ref) => {
    const { applicationLinks, applicationSocialLinks = [], applicationStaticItems = [], children, className, columns, isApplication = false, isDNV = false, linkedIn, size, variant, isSlim } = props, rest = __rest(props, ["applicationLinks", "applicationSocialLinks", "applicationStaticItems", "children", "className", "columns", "isApplication", "isDNV", "linkedIn", "size", "variant", "isSlim"]);
    const context = { size, variant };
    const styles = (0, core_1.useStyleConfig)('Footer', props);
    if (isApplication && !applicationLinks)
        console.error('Footer: isApplication is true but applicationLinks  not set.');
    const slimLinks = [
        {
            id: 'home',
            text: 'veracity.com',
            url: 'https://www.veracity.com/',
        },
    ];
    columns === null || columns === void 0 ? void 0 : columns.map(column => {
        column.map(section => {
            var _a;
            (_a = section.links) === null || _a === void 0 ? void 0 : _a.map(link => {
                if (!link)
                    return;
                if (['home', 'support', 'status'].includes(link.id || ''))
                    slimLinks.push(link);
            });
        });
    });
    const downMd = (0, core_1.useDown)('md');
    const downLg = (0, core_1.useDown)('lg');
    return ((0, jsx_runtime_1.jsx)(context_1.FooterProvider, { value: context, children: (0, jsx_runtime_1.jsxs)(exports.FooterBase, Object.assign({ className: (0, utils_1.cs)('vui-footer', isApplication ? 'vui-footer-app' : '', className), px: isApplication ? '40px' : 3, py: isSlim ? (downMd ? '16px' : '9px') : 5, role: "contentinfo" }, styles.container, { ref: ref }, rest, { children: [isApplication && ((0, jsx_runtime_1.jsx)(footerContent_1.default, { alignContent: "center", alignItems: "center", maxW: "100%", children: (0, jsx_runtime_1.jsxs)(footerRow_1.default, { alignContent: "space-between", w: 1, children: [(0, jsx_runtime_1.jsx)(box_1.Box, { alignItems: "self-start", columnGap: 3, flex: { xs: '0 0 100%', sm: '0 0 100%', md: '0 0 100%', lg: '0 0 50%' }, py: { xs: 1, sm: 1, md: 1.25, lg: 1.5 }, wrap: true, children: applicationLinks === null || applicationLinks === void 0 ? void 0 : applicationLinks.map((link, index) => ((0, jsx_runtime_1.jsxs)(box_1.Box, { flex: { xs: '0 0 50%', sm: '0 0 auto' }, children: [link.items && ((0, jsx_runtime_1.jsxs)(menu_1.default, Object.assign({ isLazy: false, offset: [-16, 9], placement: "top-start", size: "lg" }, rest, { children: [(0, jsx_runtime_1.jsx)(menu_1.default.Button, Object.assign({ as: link_1.Link, className: "vui-footerLink-trigger", pt: "3px", role: "button", text: link.text, title: link.text }, styles.link, rest)), (0, jsx_runtime_1.jsx)(menu_1.default.List, Object.assign({ maxH: 400, right: 0, w: 320 }, styles.list, { children: link.items.map(({ text, url }, index) => ((0, jsx_runtime_1.jsx)(menu_1.default.Item, Object.assign({ isTruncated: true, linkProps: { href: url }, text: text, title: text }, styles.item), index))) }))] }))), !link.items && (0, jsx_runtime_1.jsx)(footerLink_1.default, Object.assign({}, link, { href: link.url }))] }, index))) }), downLg && (0, jsx_runtime_1.jsx)(divider_1.Divider, { borderColor: "sandstone.main", mb: 0.5, mt: 1, w: 1 }), (0, jsx_runtime_1.jsxs)(box_1.Box, { centerV: true, columnGap: 3, flex: { xs: '0 0 100%', sm: '0 0 100%', md: '0 0 100%', lg: '0 0 50%' }, justifyContent: { sm: 'center', lg: 'flex-end' }, py: { xs: 1, sm: 1, md: 1.25, lg: 1.5 }, wrap: true, children: [applicationStaticItems === null || applicationStaticItems === void 0 ? void 0 : applicationStaticItems.map((text, index) => ((0, jsx_runtime_1.jsx)(box_1.Box, { children: (0, jsx_runtime_1.jsx)(t_1.T, { size: "sm", children: text }) }, index))), isDNV ? ((0, jsx_runtime_1.jsx)(box_1.Box, { children: (0, jsx_runtime_1.jsxs)(t_1.T, { size: "sm", children: ["\u00A9 DNV AS ", currentYear] }) })) : ((0, jsx_runtime_1.jsx)(box_1.Box, { children: (0, jsx_runtime_1.jsxs)(t_1.T, { size: "sm", children: [(0, jsx_runtime_1.jsx)(t_1.T, { weight: "demi", children: "Veracity by DNV" }), ", DNV AS"] }) })), (0, jsx_runtime_1.jsxs)(box_1.Box, { children: [applicationSocialLinks === null || applicationSocialLinks === void 0 ? void 0 : applicationSocialLinks.map((link, index) => ((0, jsx_runtime_1.jsx)(link_1.Link, Object.assign({ "aria-label": link.text, fontWeight: "demi", href: link.url, iconLeft: (0, jsx_runtime_1.jsx)(link_1.Link.Icon, { name: `cubCircle${link.text}`, radius: "50%", size: "xs" }), isExternal: true, mr: 1, size: { _: 'sm', md: 'md' } }, styles.link), index))), (0, jsx_runtime_1.jsx)(link_1.Link, Object.assign({ fontWeight: "demi", href: linkedIn !== null && linkedIn !== void 0 ? linkedIn : footerTrademark_1.defaultLinkedInUrl, isExternal: true, size: { _: 'sm', md: 'md' } }, styles.link, { children: (0, jsx_runtime_1.jsx)(footerHeading_1.default, { fontSize: "16px", mb: 0, text: "Follow us" }) }))] })] })] }) })), !isApplication && isSlim && ((0, jsx_runtime_1.jsx)(footerContent_1.default, { alignContent: "center", alignItems: "center", maxW: { xs: 343, sm: 305, md: 720, lg: 975 }, children: (0, jsx_runtime_1.jsxs)(footerRow_1.default, { children: [slimLinks.map(({ text, url, id }, index) => {
                                /** if the screen is small drop one specific link */
                                if (downLg && id === 'support')
                                    return;
                                return ((0, jsx_runtime_1.jsx)(footerSlimColumn_1.default, { children: (0, jsx_runtime_1.jsx)(footerLink_1.default, { href: url, text: text }) }, index));
                            }), downMd && (0, jsx_runtime_1.jsx)(divider_1.Divider, { borderColor: "sandstone.main", mb: 0.5, mt: 1, w: 1 }), (0, jsx_runtime_1.jsx)(footerSlimColumn_1.default, { centerV: true, children: (0, jsx_runtime_1.jsxs)(t_1.T, { size: "xs", children: [(0, jsx_runtime_1.jsx)(t_1.T, { weight: "demi", children: "Veracity by DNV" }), ", DNV AS"] }) }), (0, jsx_runtime_1.jsx)(footerSlimColumn_1.default, { children: (0, jsx_runtime_1.jsx)(link_1.Link, Object.assign({ fontWeight: "demi", href: linkedIn !== null && linkedIn !== void 0 ? linkedIn : footerTrademark_1.defaultLinkedInUrl, iconLeft: (0, jsx_runtime_1.jsx)(link_1.Link.Icon, { mr: 1, name: "cubCircleLinkedIn", radius: "50%", size: "xs" }), isExternal: true, size: { _: 'sm', md: 'md' } }, styles.link, { children: (0, jsx_runtime_1.jsx)(footerHeading_1.default, { fontSize: "16px", mb: 0, text: "Follow us" }) })) })] }) })), !isApplication && !isSlim && ((0, jsx_runtime_1.jsxs)(footerContent_1.default, { children: [children !== null && children !== void 0 ? children : (columns && ((0, jsx_runtime_1.jsx)(footerRow_1.default, { children: columns.map((sections, index) => ((0, jsx_runtime_1.jsx)(footerColumn_1.default, { sections: sections }, index))) }))), children || columns ? (0, jsx_runtime_1.jsx)(divider_1.Divider, { borderColor: "sandstone.main", my: 4 }) : null, (0, jsx_runtime_1.jsx)(footerRow_1.default, { children: (0, jsx_runtime_1.jsx)(footerTrademark_1.FooterTrademark, { linkedIn: linkedIn }) })] }))] })) }));
});
exports.Footer.Column = footerColumn_1.default;
exports.Footer.Content = footerContent_1.default;
exports.Footer.Heading = footerHeading_1.default;
exports.Footer.Link = footerLink_1.default;
exports.Footer.Row = footerRow_1.default;
exports.Footer.Section = footerSection_1.default;
exports.Footer.displayName = 'Footer';
exports.default = exports.Footer;
//# sourceMappingURL=footer.js.map