'use strict';

var jsxRuntime = require('react/jsx-runtime');
var index = require('../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.cjs');
var React = require('react');
var spinner = require('../spinner/spinner.cjs');
var button_module = require('./button.module.css.cjs');
var index$1 = require('../../node_modules/.pnpm/@radix-ui_react-slot@1.2.3_@types_react@19.1.9_react@19.2.1/node_modules/@radix-ui/react-slot/dist/index.cjs');

const button = index.cva(button_module.default['button'], {
    variants: {
        variant: {
            solid: button_module.default['button-solid'],
            outline: button_module.default['button-outline'],
            ghost: button_module.default['button-ghost'],
            text: button_module.default['button-text']
        },
        size: {
            small: button_module.default['button-small'],
            normal: button_module.default['button-normal']
        },
        disabled: {
            true: button_module.default['button-disabled']
        },
        loading: {
            true: button_module.default['button-loading']
        },
        color: {
            accent: button_module.default['button-color-accent'],
            danger: button_module.default['button-color-danger'],
            neutral: button_module.default['button-color-neutral'],
            success: button_module.default['button-color-success']
        }
    },
    compoundVariants: [
        {
            variant: 'solid',
            color: 'accent',
            className: button_module.default['button-solid-accent']
        },
        {
            variant: 'solid',
            color: 'danger',
            className: button_module.default['button-solid-danger']
        },
        {
            variant: 'solid',
            color: 'neutral',
            className: button_module.default['button-solid-neutral']
        },
        {
            variant: 'solid',
            color: 'success',
            className: button_module.default['button-solid-success']
        },
        {
            variant: 'outline',
            color: 'accent',
            className: button_module.default['button-outline-accent']
        },
        {
            variant: 'outline',
            color: 'danger',
            className: button_module.default['button-outline-danger']
        },
        {
            variant: 'outline',
            color: 'neutral',
            className: button_module.default['button-outline-neutral']
        },
        {
            variant: 'outline',
            color: 'success',
            className: button_module.default['button-outline-success']
        },
        {
            variant: 'ghost',
            color: 'accent',
            className: button_module.default['button-ghost-accent']
        },
        {
            variant: 'ghost',
            color: 'danger',
            className: button_module.default['button-ghost-danger']
        },
        {
            variant: 'ghost',
            color: 'neutral',
            className: button_module.default['button-ghost-neutral']
        },
        {
            variant: 'ghost',
            color: 'success',
            className: button_module.default['button-ghost-success']
        },
        {
            variant: 'text',
            color: 'accent',
            className: button_module.default['button-text-accent']
        },
        {
            variant: 'text',
            color: 'danger',
            className: button_module.default['button-text-danger']
        },
        {
            variant: 'text',
            color: 'neutral',
            className: button_module.default['button-text-neutral']
        },
        {
            variant: 'text',
            color: 'success',
            className: button_module.default['button-text-success']
        }
    ],
    defaultVariants: {
        variant: 'solid',
        size: 'normal',
        color: 'accent'
    }
});
const getLoaderOnlyClass = (size) => size === 'small'
    ? button_module.default['loader-only-button-small']
    : button_module.default['loader-only-button-normal'];
const Button = React.forwardRef(({ className, variant = 'solid', color = 'accent', size = 'normal', asChild = false, disabled, loading, loaderText, leadingIcon, trailingIcon, maxWidth, width, style = {}, children, ...props }, ref) => {
    const Comp = asChild ? index$1.Root : 'button';
    const isLoaderOnly = loading && !loaderText;
    const widthStyle = { maxWidth, width };
    const buttonStyle = { ...widthStyle, ...style };
    return (jsxRuntime.jsx(Comp, { className: `${button({ variant, size, color, disabled, loading, className })} ${isLoaderOnly ? getLoaderOnlyClass(size) : ''}`, ref: ref, disabled: disabled, style: buttonStyle, ...props, children: loading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(spinner.Spinner, { size: 1, color: 'default' }), loaderText && (jsxRuntime.jsx("span", { className: button_module.default['loader-text'], children: loaderText }))] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [leadingIcon && (jsxRuntime.jsx("span", { className: `${button_module.default['icon']} ${button_module.default['icon-leading']}`, children: leadingIcon })), children, trailingIcon && (jsxRuntime.jsx("span", { className: `${button_module.default['icon']} ${button_module.default['icon-trailing']}`, children: trailingIcon }))] })) }));
});
Button.displayName = 'Button';

exports.Button = Button;
//# sourceMappingURL=button.cjs.map
