"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.iconVariants = exports.buttonVariants = void 0;
exports.Button = Button;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_slot_1 = require("@radix-ui/react-slot");
const class_variance_authority_1 = require("class-variance-authority");
const utils_1 = require("../../../lib/utils");
const buttonVariants = (0, class_variance_authority_1.cva)('button-base button-disabled button-read-only', {
    variants: {
        variant: {
            plain: 'button-plain',
            hoverLink: 'hover:bg-accent text-foreground hover:text-accent-foreground font-normal',
            default: 'button-primary',
            primary: 'button-primary',
            secondary: 'button-secondary',
            tertiary: 'button-tertiary',
            outline: 'button-outline',
            link: 'button-link'
        },
        fullWidth: {
            true: 'w-full',
            false: 'w-fit'
        },
        size: {
            default: '',
            small: 'button-small'
        }
    },
    defaultVariants: {
        variant: 'default',
        size: 'default'
    }
});
exports.buttonVariants = buttonVariants;
const iconVariants = (0, class_variance_authority_1.cva)('', {
    variants: {
        position: {
            start: 'mr-2',
            end: 'ml-2',
            'far-end': 'absolute right-2'
        },
        size: {
            default: '[&>*]:size-6',
            small: '[&>*]:size-4'
        }
    },
    defaultVariants: {
        position: 'start',
        size: 'default'
    }
});
exports.iconVariants = iconVariants;
function Button({ className, variant, size, asChild = false, icon, iconPlacement = 'start', fullWidth = false, readOnly = false, onClick, ...props }) {
    const Comp = asChild ? react_slot_1.Slot : 'button';
    const handleClick = (e) => {
        if (readOnly) {
            e.preventDefault();
            return;
        }
        onClick?.(e);
    };
    return ((0, jsx_runtime_1.jsxs)(Comp, { className: (0, utils_1.cn)(buttonVariants({ variant, size, fullWidth }), className), "data-read-only": readOnly, "data-slot": "button", ...props, onClick: handleClick, children: [icon && iconPlacement === 'start' && ((0, jsx_runtime_1.jsx)("span", { className: (0, utils_1.cn)(iconVariants({ position: iconPlacement, size })), children: icon })), props.children, icon && iconPlacement !== 'start' && ((0, jsx_runtime_1.jsx)("span", { className: (0, utils_1.cn)(iconVariants({ position: iconPlacement, size })), children: icon }))] }));
}
