"use strict";
var __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RealtimeEvents = exports.userToGroupsMapper = exports.groupFilter = exports.GROUP_VALUES = exports.UserGroupTypes = exports.UserEvents = exports.ROUTES = exports.baseRoute = exports.successExtractor = exports.countExtractor = exports.usersExtractor = exports.userExtractor = exports.defaultExtractor = exports.UsersScopes = void 0;
var UserHelpers_1 = require("./UserHelpers");
var UsersScopes;
(function (UsersScopes) {
    UsersScopes["DRIVERS"] = "drivers";
    UsersScopes["DISPATCHERS"] = "dispatchers";
    UsersScopes["ADMINS"] = "admins";
    UsersScopes["CUSTOMERS"] = "customers";
    UsersScopes["MARKED_AS_ONLINE"] = "marked_as_online";
})(UsersScopes = exports.UsersScopes || (exports.UsersScopes = {}));
var defaultExtractor = function (response) { return response; };
exports.defaultExtractor = defaultExtractor;
var userExtractor = function (response) { return response.user; };
exports.userExtractor = userExtractor;
var usersExtractor = function (response) { return response.users; };
exports.usersExtractor = usersExtractor;
var countExtractor = function (response) { return response.count; };
exports.countExtractor = countExtractor;
var successExtractor = function (response) { return response.success; };
exports.successExtractor = successExtractor;
exports.baseRoute = '/users';
exports.ROUTES = {
    GET_ALL: exports.baseRoute,
    GET_DRIVERS_BY_TEAM: '/teams/{:teamId}/users',
    UNLOCK: "".concat(exports.baseRoute, "/{:userId}/unlock"),
    MESSAGE_DRIVER: '/announcement/user/{:userId}',
    VALIDATE_PHONE: '/api/user/validate_phone',
    DELETE_MANY: '/users/batch_delete',
    DRIVER_COST: '/users/{:userId}/driver_cost',
    GET_USERS_WITH_USER_TYPE: '/user_types/{:userTypeId}/users',
    INVITE: '/users/{:userId}/reinvite',
    CLOSED_TASKS: '/users/{:userId}/tasks/closed_tasks',
    TOTAL_TASKS: '/users/{:userId}/tasks/count'
};
var UserEvents;
(function (UserEvents) {
    UserEvents["CURRENT_USER_UPDATED"] = "currentUserUpdated";
})(UserEvents = exports.UserEvents || (exports.UserEvents = {}));
var UserGroupTypes;
(function (UserGroupTypes) {
    UserGroupTypes["Main"] = "main";
})(UserGroupTypes = exports.UserGroupTypes || (exports.UserGroupTypes = {}));
var GROUP_VALUES;
(function (GROUP_VALUES) {
    GROUP_VALUES["OfflineDrivers"] = "OfflineDrivers";
    GROUP_VALUES["OnlineDrivers"] = "OnlineDrivers";
    GROUP_VALUES["OnShiftDrivers"] = "OnShiftDrivers";
    GROUP_VALUES["Customers"] = "Customers";
    GROUP_VALUES["Admins"] = "Admins";
    GROUP_VALUES["Dispatchers"] = "Dispatchers";
    GROUP_VALUES["Drivers"] = "Drivers";
})(GROUP_VALUES = exports.GROUP_VALUES || (exports.GROUP_VALUES = {}));
exports.groupFilter = new Map([
    [GROUP_VALUES.OfflineDrivers, UserHelpers_1.UserHelpers.isOfflineDriver],
    [GROUP_VALUES.OnlineDrivers, UserHelpers_1.UserHelpers.isOnlineDriver],
    [GROUP_VALUES.OnShiftDrivers, UserHelpers_1.UserHelpers.isOnShiftDriver],
    [GROUP_VALUES.Customers, UserHelpers_1.UserHelpers.isCustomer],
    [GROUP_VALUES.Admins, UserHelpers_1.UserHelpers.isAdmin],
    [GROUP_VALUES.Dispatchers, UserHelpers_1.UserHelpers.isDispatcher],
    [GROUP_VALUES.Drivers, UserHelpers_1.UserHelpers.isDriver]
]);
var groupKeys = Array.from(exports.groupFilter.keys());
var userToGroupsMapper = function (user) {
    var e_1, _a;
    var groups = [];
    try {
        for (var groupKeys_1 = __values(groupKeys), groupKeys_1_1 = groupKeys_1.next(); !groupKeys_1_1.done; groupKeys_1_1 = groupKeys_1.next()) {
            var groupKey = groupKeys_1_1.value;
            var filterFn = exports.groupFilter.get(groupKey);
            if (filterFn(user) === true) {
                groups.push(groupKey);
            }
        }
    }
    catch (e_1_1) { e_1 = { error: e_1_1 }; }
    finally {
        try {
            if (groupKeys_1_1 && !groupKeys_1_1.done && (_a = groupKeys_1.return)) _a.call(groupKeys_1);
        }
        finally { if (e_1) throw e_1.error; }
    }
    return groups;
};
exports.userToGroupsMapper = userToGroupsMapper;
var RealtimeEvents;
(function (RealtimeEvents) {
    RealtimeEvents["Update"] = "employee update";
    RealtimeEvents["Create"] = "new employee";
    RealtimeEvents["Delete"] = "delete employee";
})(RealtimeEvents = exports.RealtimeEvents || (exports.RealtimeEvents = {}));
//# sourceMappingURL=User.consts.js.map