"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Select = 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 ui_1 = require("../../ui");
const dropdown_1 = require("./dropdown");
const text_1 = require("./text");
exports.Select = (0, react_1.forwardRef)(({ value, onValueChange, placeholder = "Select...", items, disabled = false, style, }, ref) => {
    const { theme } = (0, theme_1.useTheme)();
    const selectedItem = items.find((item) => item.value === value);
    return ((0, jsx_runtime_1.jsxs)(dropdown_1.DropdownMenu, { children: [(0, jsx_runtime_1.jsx)(dropdown_1.DropdownMenuTrigger, { disabled: disabled, children: (0, jsx_runtime_1.jsx)(react_native_1.View, { ref: ref, style: [
                        {
                            width: "100%",
                            paddingHorizontal: theme.spacing[3],
                            paddingVertical: theme.spacing[3],
                            borderWidth: 1,
                            borderColor: theme.colors.border,
                            borderRadius: theme.borderRadius.md,
                            backgroundColor: disabled
                                ? theme.colors.muted
                                : theme.colors.card,
                            minHeight: theme.touchTargets.minimum,
                            opacity: disabled ? 0.5 : 1,
                        },
                        style,
                    ], children: (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: {
                            flexDirection: "row",
                            alignItems: "center",
                            justifyContent: "space-between",
                            width: "100%",
                            gap: 8,
                        }, children: [(0, jsx_runtime_1.jsx)(text_1.Text, { style: {
                                    fontSize: 16,
                                    color: disabled
                                        ? theme.colors.textDisabled
                                        : theme.colors.text,
                                    flex: 1,
                                }, children: selectedItem?.label || placeholder }), (0, jsx_runtime_1.jsx)(lucide_react_native_1.ChevronDown, { size: 16, color: theme.colors.textMuted })] }) }) }), (0, jsx_runtime_1.jsx)(dropdown_1.ResponsiveDropdownMenuContent, { align: "start", style: [
                    {
                        maxHeight: 400,
                    },
                ], children: items.map((item, index) => ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsx)(dropdown_1.DropdownMenuItem, { onPress: () => onValueChange(item.value), children: (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: {
                                    flexDirection: "row",
                                    alignItems: "center",
                                    justifyContent: "space-between",
                                    width: "100%",
                                    gap: 8,
                                }, children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [ui_1.gap.all[1], ui_1.py[1], ui_1.flex.values[1]], children: [(0, jsx_runtime_1.jsx)(text_1.Text, { style: {
                                                    fontWeight: item.value === value ? "500" : "400",
                                                }, color: item.value === value ? "primary" : "default", children: item.label }), item.description && ((0, jsx_runtime_1.jsx)(text_1.Text, { size: "sm", color: "muted", children: item.description }))] }), item.value === value ? ((0, jsx_runtime_1.jsx)(lucide_react_native_1.Check, { size: 16, color: theme.colors.primary })) : ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: { width: 16 } }))] }) }), index < items.length - 1 && (0, jsx_runtime_1.jsx)(dropdown_1.DropdownMenuSeparator, {})] }, item.value))) })] }));
});
exports.Select.displayName = "Select";
//# sourceMappingURL=select.js.map