"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.HeaderLinkItem = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const core_1 = require("../core");
const list_1 = __importDefault(require("../list"));
const utils_1 = require("../utils");
const context_1 = require("./context");
/** Individual link item of the Header. */
exports.HeaderLinkItem = (0, core_1.vui)((props, ref) => {
    var _a;
    const { className, icon, isActive, linkProps, onClick: onClickProp, url } = props, rest = __rest(props, ["className", "icon", "isActive", "linkProps", "onClick", "url"]);
    const { isMobile, setIsMobileOpen } = (_a = (0, context_1.useHeaderContext)()) !== null && _a !== void 0 ? _a : {};
    const styles = (0, core_1.useStyleConfig)('Header', (0, context_1.useHeaderContext)()).linkItem;
    const onClick = (0, utils_1.useCallbackRef)((e) => {
        setIsMobileOpen(false);
        onClickProp === null || onClickProp === void 0 ? void 0 : onClickProp(e);
    });
    const linkPropsExtended = Object.assign(Object.assign({}, linkProps), { display: 'inline-flex', alignItems: 'center' });
    const linkActiveProps = isActive
        ? isMobile
            ? {
                bg: 'skyBlue.95',
                borderColor: 'seaBlue.main',
                borderLeftWidth: 3,
                hoverBg: 'skyBlue.90',
                pl: '13px',
                activeBorderBottomWidth: 0,
                pt: '0px',
            }
            : { borderBottomWidth: 4, pt: '4px' }
        : {};
    const linkMobileProps = isMobile
        ? {
            color: 'darkBlue.main',
            hoverColor: 'darkBlue.main',
            hoverBg: 'skyBlue.90',
            activeColor: 'darkBlue.main',
            activeBg: 'transparent',
            activeBorderColor: 'seaBlue.main',
            activeBorderLeftWidth: 0,
            pt: '0',
            activePl: isActive ? '13px' : '16px',
        }
        : { activeBorderBottomWidth: 0, pt: '0px', activePt: isActive ? '1px' : '0' };
    const itemScreenProps = isMobile ? {} : { display: 'inline-flex', fontWeight: 'medium', h: '100%' };
    return ((0, jsx_runtime_1.jsx)(list_1.default.Item, Object.assign({ className: (0, utils_1.cs)('vui-headerLinkItem', className, `${isActive && 'is-active'}`), iconLeft: icon, linkProps: Object.assign(Object.assign(Object.assign(Object.assign({ href: url, ringInset: true, transition: 'all 0.1s, border-width 0s, padding 0s', w: { xs: '100%', lg: 'max-content' }, px: { xs: '16px', lg: '10px', xl: '16px' } }, styles.link), linkPropsExtended), linkMobileProps), linkActiveProps), onClick: onClick, ref: ref }, itemScreenProps, styles.container, rest)));
});
exports.HeaderLinkItem.displayName = 'HeaderLinkItem';
exports.default = exports.HeaderLinkItem;
//# sourceMappingURL=headerLinkItem.js.map