"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RoutesWrap = void 0;
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var react_router_dom_1 = require("react-router-dom");
var auth_1 = require("../Auth/auth");
var build_1 = require("../Build/build");
var v_eris_1 = require("v-eris");
require("./routes.wrap.scss");
var RoutesWrap = function (props) {
    var auth = (0, react_1.useContext)(auth_1.AuthContext);
    var lang = (0, react_1.useContext)(v_eris_1.LangContext);
    var build = (0, react_1.useContext)(build_1.BuildContext);
    var tryAccess = function (element) {
        return auth.access < 3 ?
            (react_1.default.createElement("div", { className: "core-deny" }, lang.get(auth.access < 1 ? "Server::Banned" : "Server::NeedConfirmation")))
            :
                (build.denyAccess ? (react_1.default.createElement("div", { className: "core-deny" }, lang.get("Server::Deny"))) : element);
    };
    var content = (0, react_1.useMemo)(function () {
        var list = [];
        for (var key in build.routes) {
            list.push(react_1.default.createElement(react_router_dom_1.Route, { key: key, path: key, element: tryAccess(build.routes[key].element) }));
        }
        ;
        return list;
    }, [build.routes, auth.access]);
    return (react_1.default.createElement("div", { className: "eris-routes-wrap-container" },
        react_1.default.createElement(react_router_dom_1.Routes, null, content)));
};
exports.RoutesWrap = RoutesWrap;
//# sourceMappingURL=routes.wrap.js.map