"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Checkbox = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const lucide_react_native_1 = require("lucide-react-native");
const react_1 = require("react");
const react_native_1 = require("react-native");
const theme_1 = require("../../lib/theme/theme");
const text_1 = require("./text");
exports.Checkbox = (0, react_1.forwardRef)(({ checked, onCheckedChange, disabled = false, size = "md", label, description, style, ...props }, ref) => {
    const { theme } = (0, theme_1.useTheme)();
    const handlePress = () => {
        if (!disabled) {
            onCheckedChange(!checked);
        }
    };
    const styles = createStyles(theme, size, disabled, checked);
    return ((0, jsx_runtime_1.jsxs)(react_native_1.TouchableOpacity, { ref: ref, style: [styles.container, style], onPress: handlePress, disabled: disabled, ...props, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.checkbox, children: checked && ((0, jsx_runtime_1.jsx)(lucide_react_native_1.Check, { size: size === "sm" ? 12 : size === "lg" ? 18 : 14, color: disabled
                        ? theme.colors.textDisabled
                        : theme.colors.primaryForeground })) }), (label || description) && ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.content, children: [label && ((0, jsx_runtime_1.jsx)(text_1.Text, { size: size === "sm" ? "sm" : size === "lg" ? "lg" : "base", color: disabled ? "muted" : "default", leading: "snug", children: label })), description && ((0, jsx_runtime_1.jsx)(text_1.Text, { size: size === "sm" ? "xs" : size === "lg" ? "base" : "sm", color: disabled ? "muted" : "muted", style: { marginTop: theme.spacing[1] }, children: description }))] }))] }));
});
exports.Checkbox.displayName = "Checkbox";
function createStyles(theme, size, disabled, checked) {
    const sizeStyles = {
        sm: {
            checkboxSize: 16,
            borderRadius: 2,
            padding: theme.spacing[1],
            gap: theme.spacing[1],
        },
        md: {
            checkboxSize: 20,
            borderRadius: 4,
            padding: theme.spacing[1],
            gap: theme.spacing[1],
        },
        lg: {
            checkboxSize: 24,
            borderRadius: 6,
            padding: theme.spacing[1],
            gap: theme.spacing[2],
        },
    };
    const currentSize = sizeStyles[size];
    return react_native_1.StyleSheet.create({
        container: {
            flexDirection: "row",
            alignItems: "flex-start",
            opacity: disabled ? 0.5 : 1,
        },
        checkbox: {
            width: currentSize.checkboxSize,
            height: currentSize.checkboxSize,
            borderWidth: 1.5,
            borderColor: disabled
                ? theme.colors.border
                : checked
                    ? theme.colors.primary
                    : theme.colors.textMuted,
            borderRadius: currentSize.borderRadius,
            backgroundColor: disabled
                ? theme.colors.muted
                : checked
                    ? theme.colors.primary
                    : "transparent",
            alignItems: "center",
            justifyContent: "center",
        },
        content: {
            flex: 1,
            paddingTop: currentSize.padding * 0.25,
            paddingLeft: theme.spacing[2],
        },
    });
}
//# sourceMappingURL=checkbox.js.map