"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const source_1 = require("./source");
/**
 * GroupSource is a source for the participant groups.
 */
class GroupSource extends source_1.Source {
    constructor() {
        super(...arguments);
        this.updater = new source_1.ResourceComparator({
            id: 'groupID',
            create: groups => ({
                method: 'onGroupCreate',
                params: { groups },
            }),
            update: groups => ({
                method: 'onGroupUpdate',
                params: { groups },
            }),
            destroy: groupID => ({
                method: 'onGroupDelete',
                params: { groupID, reassignGroupID: 'default' },
            }),
        });
    }
    /**
     * @override
     */
    compare(previous, next) {
        return this.updater.compare(previous, next);
    }
    /**
     * @override
     */
    sourceProp() {
        return 'groups';
    }
    /**
     * @override
     */
    createPacket(source) {
        return [
            {
                method: 'onGroupCreate',
                params: { groups: source },
            },
        ];
    }
}
exports.GroupSource = GroupSource;
