import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__chakra_ui_react__ from "@chakra-ui/react";
import * as __WEBPACK_EXTERNAL_MODULE_react_router_dom__ from "react-router-dom";
import * as __WEBPACK_EXTERNAL_MODULE__statusHelper_mjs__ from "./statusHelper.mjs";
const getIsDisabled = (isDisabledProp, status)=>'error' === status || isDisabledProp;
function NavLink(props) {
    const { title, to, icon, onClick, isPrevious = false, isIconOnly = false, isCollapsed = false, isExternal = false, isDisabled = false, disabledText, status = 'success' } = props;
    const skeletonItem = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Grid, {
        alignContent: "center",
        height: "40px",
        padding: "0.75rem",
        opacity: "0.5"
    }, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Skeleton, {
        height: "27px"
    }));
    const renderItem = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Flex, {
        alignItems: "center"
    }, !!icon && /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Icon, {
        "data-testid": `nav-link-icon-${title}`,
        as: icon,
        w: "1.2rem",
        h: "1.2rem",
        mr: 3
    }), isCollapsed || isIconOnly ? /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.chakra.span, {
        userSelect: "none"
    }, "\xa0") // necessary for spacing correctly
     : /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.chakra.span, {
        "data-testid": `nav-link-${title}`
    }, title));
    const activeLink = isExternal ? /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Link, {
        href: to,
        variant: "nav",
        isExternal: true,
        onClick: onClick,
        "data-testid": "nav-link"
    }, renderItem) : /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Link, {
        as: __WEBPACK_EXTERNAL_MODULE_react_router_dom__.NavLink,
        to: to,
        variant: "nav",
        onClick: onClick
    }, renderItem);
    const disabledLink = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Tooltip, {
        label: disabledText,
        placement: "right",
        hasArrow: true
    }, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Link, {
        variant: "nav-disabled",
        ...(0, __WEBPACK_EXTERNAL_MODULE__statusHelper_mjs__.statusToProps)(status)
    }, renderItem));
    const previousLink = /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Tooltip, {
        label: "Go back",
        placement: "right",
        hasArrow: true
    }, /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Link, {
        variant: "nav-previous",
        "data-testid": "nav-link-previous",
        ...(0, __WEBPACK_EXTERNAL_MODULE__statusHelper_mjs__.statusToProps)(status),
        as: __WEBPACK_EXTERNAL_MODULE_react_router_dom__.NavLink,
        to: to,
        onClick: onClick
    }, renderItem));
    if ('loading' === status) return skeletonItem;
    if (isPrevious) return previousLink;
    if (getIsDisabled(isDisabled, status)) return disabledLink;
    if (isCollapsed) return /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(__WEBPACK_EXTERNAL_MODULE__chakra_ui_react__.Tooltip, {
        label: title,
        placement: "right",
        hasArrow: true
    }, activeLink);
    return activeLink;
}
/* ESM default export */ const NavLink_rslib_entry_ = NavLink;
export { NavLink_rslib_entry_ as default };
