"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.processChannelOptions = processChannelOptions;
const channelRelation_1 = require("../../../discussions/api/enums/channelRelation");
const channelSort_1 = require("../../../discussions/api/enums/channelSort");
const sortOrder_1 = require("../../../discussions/api/enums/sortOrder");
const SORT_FIELD_MAP = {
    access: channelSort_1.ChannelSort.ACCESS,
    created: channelSort_1.ChannelSort.CREATED_AT,
    modified: channelSort_1.ChannelSort.UPDATED_AT,
    owner: channelSort_1.ChannelSort.CREATOR,
    lastActivity: channelSort_1.ChannelSort.LAST_ACTIVITY,
};
const SORT_ORDER_MAP = {
    desc: sortOrder_1.SortOrder.DESC,
    asc: sortOrder_1.SortOrder.ASC,
};
/**
 * @private
 * Converts an IHubSearchOptions object into a partial ISearchChannels
 * object of paging & sort parameters
 * @param options An IHubSearchOptions object
 * @returns a partial ISearchChannels object
 */
function processChannelOptions(options) {
    const channelOptions = {
        relations: [channelRelation_1.ChannelRelation.CHANNEL_ACL],
    };
    if (options.num) {
        channelOptions.num = options.num;
    }
    if (options.start) {
        channelOptions.start = options.start;
    }
    if (options.sortField && SORT_FIELD_MAP[options.sortField]) {
        channelOptions.sortBy = SORT_FIELD_MAP[options.sortField];
    }
    if (options.sortOrder && SORT_ORDER_MAP[options.sortOrder]) {
        channelOptions.sortOrder = SORT_ORDER_MAP[options.sortOrder];
    }
    return channelOptions;
}
//# sourceMappingURL=processChannelOptions.js.map