import { jsx as _jsx } from "react/jsx-runtime";
import React from "react";
import { PulseLoader } from "react-spinners";
import { useTheme } from "styled-components";
import { ButtonWrapper as Wrapper, LinkButtonWrapper as LinkWrapper, TextButtonWrapper as TextWrapper, } from "./styled";
import { DefaultTheme } from "../../theme";
const Loader = ({ color }) => {
    return _jsx(PulseLoader, { size: 8, color: color || "white" });
};
const Button = ({ pending, children, type, color, theme, ...props }) => {
    const appTheme = useTheme();
    const currentTheme = React.useMemo(() => ({ ...(DefaultTheme ?? {}), ...(appTheme ?? {}), ...(theme ?? {}) }), [appTheme, theme]);
    return (_jsx(Wrapper, { pending: pending, type: type || "button", style: { pointerEvents: pending ? "none" : "auto" }, theme: currentTheme, ...props, children: pending ? (_jsx(Loader, { color: props.outlined || props.thinOutlined || props.texted
                ? currentTheme.button?.background
                : currentTheme.button?.outlinedBackground })) : (children) }));
};
export const LinkButton = ({ children, theme, ...props }) => {
    const appTheme = useTheme();
    const currentTheme = React.useMemo(() => ({ ...(DefaultTheme ?? {}), ...(appTheme ?? {}), ...(theme ?? {}) }), [appTheme, theme]);
    return (_jsx(LinkWrapper, { theme: currentTheme, ...props, children: children }));
};
export const TextLinkButton = ({ children, theme, ...props }) => {
    const appTheme = useTheme();
    const currentTheme = React.useMemo(() => ({ ...(DefaultTheme ?? {}), ...(appTheme ?? {}), ...(theme ?? {}) }), [appTheme, theme]);
    return (_jsx(TextWrapper, { theme: currentTheme, ...props, children: children }));
};
export default Object.assign(Button, {
    Link: LinkButton,
    TextLink: TextLinkButton,
});
//# sourceMappingURL=index.js.map