import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export function VEnvironmentFacet({ buckets, name }) {
    const options = buckets.map((bucket) => ({
        label: `(${bucket.count})`,
        value: bucket._id
    }));
    const filterGroup = {
        name: name.charAt(0).toUpperCase() + name.slice(1),
        options: options,
        type: "select",
        labelRenderer: (environmentId) => {
            const bucket = buckets.find(b => b._id === environmentId);
            const displayName = bucket?.name || environmentId;
            return (_jsxs("div", { className: "w-full flex items-center", children: [_jsx("span", { className: "text-sm truncate", children: displayName }), _jsxs("span", { className: "ml-2 text-xs", children: ["(", bucket?.count || 0, ")"] })] }));
        },
        filterBy: (optionValue, searchText) => {
            const bucket = buckets.find(b => b._id === optionValue);
            const searchName = bucket?.name || optionValue;
            return searchName.toLowerCase().includes(searchText.toLowerCase());
        }
    };
    return filterGroup;
}
//# sourceMappingURL=VEnvironmentFacet.js.map