"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseAccount = void 0;
const ability_1 = require("@casl/ability");
const buildAccountHelpers_1 = require("./buildAccountHelpers");
/**
 * Reconstruct the full account with abilities and helper methods
 */
const parseAccount = (deserializedAccount) => {
    const account = {
        ...deserializedAccount,
        user: {
            ...deserializedAccount.user,
            ability: new ability_1.Ability(deserializedAccount.user.abilityRules),
        },
        ...(0, buildAccountHelpers_1.buildAccountHelpers)(deserializedAccount),
    };
    switch (account.authentication.type) {
        case 'session':
            return account;
        case 'pat':
            return account;
        case 'jwt':
            return account;
        case 'service-account':
            return account;
        default:
            return account;
    }
};
exports.parseAccount = parseAccount;
//# sourceMappingURL=parseAccount.js.map