"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.filterByProfile = exports.annotateUsageProfile = exports.normalizeProfileQuery = void 0;
const PROFILE_NAME_REGEX = /^[A-Za-z0-9._-]+$/;
function normalizeProfileQuery(profile) {
    const value = profile?.trim();
    if (!value || value === 'all')
        return undefined;
    if (!PROFILE_NAME_REGEX.test(value)) {
        throw new Error('Invalid profile filter');
    }
    return value;
}
exports.normalizeProfileQuery = normalizeProfileQuery;
function annotateUsageProfile(data, profile) {
    return {
        daily: data.daily.map((item) => ({ ...item, profile })),
        hourly: data.hourly.map((item) => ({ ...item, profile })),
        monthly: data.monthly.map((item) => ({ ...item, profile })),
        session: data.session.map((item) => ({ ...item, profile })),
    };
}
exports.annotateUsageProfile = annotateUsageProfile;
function filterByProfile(data, profile) {
    if (!profile)
        return data;
    return data.filter((item) => item.profile === profile);
}
exports.filterByProfile = filterByProfile;
//# sourceMappingURL=profile-filter.js.map