import { mergeProps, splitProps } from "solid-js";
import classNames from "./classnames";
import { Anchor, useNavItem, makeEventKey, } from "solid-bootstrap-core";
import { useBootstrapPrefix } from "./ThemeProvider";
import { Dynamic } from "solid-js/web";
const defaultProps = {
    as: Anchor,
    disabled: false,
};
const NavLink = (p) => {
    const [local, props] = splitProps(mergeProps(defaultProps, p), [
        "as",
        "bsPrefix",
        "className",
        "active",
        "eventKey",
    ]);
    const bsPrefix = useBootstrapPrefix(local.bsPrefix, "nav-link");
    const [navItemProps, meta] = useNavItem(mergeProps({
        get key() {
            return makeEventKey(local.eventKey, props.href);
        },
        get active() {
            return local.active;
        },
    }, props));
    return (<Dynamic component={local.as} {...props} {...navItemProps} className={classNames(local.className, bsPrefix, props.disabled && "disabled", meta.isActive && "active")}>
      {props.children}
    </Dynamic>);
};
export default NavLink;
