"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
require("moment/locale/zh-cn");
const react_1 = __importStar(require("react"));
const react_router_dom_1 = require("react-router-dom");
const antd_1 = require("antd");
const en_US_1 = __importDefault(require("antd/lib/locale/en_US"));
const zh_CN_1 = __importDefault(require("antd/lib/locale/zh_CN"));
const styled_components_1 = __importDefault(require("styled-components"));
const index_1 = require("@/constants/index");
const index_2 = __importDefault(require("@/foxI18n/index"));
const index_3 = require("@/utils/index");
const index_4 = require("./system/index");
const builder_1 = require("./builder");
const Root = styled_components_1.default.div `
  height: 100%;
`;
const AppMain = () => {
    const [locale, setLocale] = (0, react_1.useState)(Object.assign(Object.assign({}, zh_CN_1.default), { business: index_2.default[index_1.LOCALE_ZH_CN] }));
    (0, react_1.useEffect)(() => {
        const { languagePrefer } = (0, index_3.getLoginUser)();
        if (!!languagePrefer)
            setLocale(Object.assign(Object.assign({}, (languagePrefer === index_1.LOCALE_ZH_CN ? zh_CN_1.default : en_US_1.default)), { business: languagePrefer === index_1.LOCALE_ZH_CN ? index_2.default[index_1.LOCALE_ZH_CN] : index_2.default[index_1.LOCALE_EN] }));
    }, []);
    (0, react_1.useEffect)(() => {
        (0, index_3.setGlobalLocale)(locale.locale);
    }, [locale]);
    return (react_1.default.createElement(index_4.GlobalContext.Provider, { value: { locale, setLocale } },
        react_1.default.createElement(antd_1.ConfigProvider, { locale: locale },
            react_1.default.createElement(Root, null,
                react_1.default.createElement(react_router_dom_1.Switch, null,
                    react_1.default.createElement(react_router_dom_1.Route, { path: "/login", component: index_4.Login }),
                    react_1.default.createElement(react_router_dom_1.Route, { path: "/register", component: index_4.Register }),
                    react_1.default.createElement(react_router_dom_1.Route, { path: "/builder", component: builder_1.Builder }),
                    react_1.default.createElement(react_router_dom_1.Route, { path: "/", component: index_4.Internal }))))));
};
exports.default = AppMain;
