"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
exports.getLocalConfig = exports.getLocalStorage = exports.simulatorStorageKey = exports.updateVersion = exports.zeppFontIcon = exports.ACCOUNT_ENV_KEY = exports.DEFAULT_PORT = exports.DEFAULT_HOST = exports.TemplateCopyType = exports.AppSourceType = exports.AppType = void 0;
var dotenv_1 = __importDefault(require("dotenv"));
var fs_1 = __importDefault(require("fs"));
var os_1 = __importDefault(require("os"));
var path_1 = __importDefault(require("path"));
var fs_extra_1 = __importDefault(require("fs-extra"));
var AppType;
(function (AppType) {
    AppType["APP"] = "app";
    AppType["WORKOUT_EXTENSION"] = "workout_extension";
    AppType["WATCHFACE"] = "watchface";
})(AppType = exports.AppType || (exports.AppType = {}));
var AppSourceType;
(function (AppSourceType) {
    AppSourceType["LOCAL"] = "local";
    AppSourceType["YEOMAN"] = "yeoman";
})(AppSourceType = exports.AppSourceType || (exports.AppSourceType = {}));
var TemplateCopyType;
(function (TemplateCopyType) {
    TemplateCopyType["CLONE"] = "clone";
    TemplateCopyType["EDIT"] = "edit";
})(TemplateCopyType = exports.TemplateCopyType || (exports.TemplateCopyType = {}));
exports.DEFAULT_HOST = '127.0.0.1';
exports.DEFAULT_PORT = '7650';
exports.ACCOUNT_ENV_KEY = 'account_env';
var localStoragePath = path_1["default"].resolve(os_1["default"].homedir(), ".zepp/.zeus");
var getLoginURL = {
    production: 'https://user.zepp.com/universalLogin/index.html#/login',
    test: 'https://user-testing.zepp.com/universalLogin/index.html#/login'
};
var getAnalyticsHost = {
    production: 'https://api-analytics.huami.com',
    test: 'https://api-analytics-test.huami.com'
};
exports.zeppFontIcon = [
    '',
    '    *********   *******    *******    ******* ',
    '    //////**/  /**/////   /**////**  /**////**',
    '         **/    /**       /**   /**  /**   /**',
    '        **/      >*****   /*******   /******* ',
    '       **/      /**///    /**////    /**////  ',
    '      **/      /**        /**        /**      ',
    '     ********  /*******   /**        /**      ',
    '    ////////  ////////   //         //       ',
    '',
].join('\n');
exports.updateVersion = [
    '',
    '╭──────────────────────────────────────────────────────╮',
    '│                                                      │',
    '│               New version available!                 │',
    '│   Changelog: https://api.huami.com/t/zeus-cli-doc    │',
    '│   Run `npm install @zeppos/zeus-cli -g` to update!   │',
    '│                                                      │',
    '╰──────────────────────────────────────────────────────╯',
    '',
].join('\n');
exports.simulatorStorageKey = {
    simulatorHost: 'simulator_host',
    simulatorPort: 'simulator_port',
    simulatorConnectStatus: "____simulator_connect_status"
};
var getLocalStorage = function () {
    fs_extra_1["default"].ensureFileSync(localStoragePath);
    return dotenv_1["default"].parse(fs_1["default"].readFileSync(localStoragePath));
};
exports.getLocalStorage = getLocalStorage;
var getLocalConfig = function () {
    var zeusStorageInfo = (0, exports.getLocalStorage)();
    var account_env = zeusStorageInfo.account_env === 'test' ? 'test' : 'production';
    var LOGIN_URL = new URL(getLoginURL[account_env]);
    var ANALYTICS_HOST = getAnalyticsHost[account_env];
    var accountPrefix = "____".concat(LOGIN_URL.host.replace(/\./g, '_'), "__");
    var loginConfig = {
        LOGIN_URL: LOGIN_URL,
        PROJECT_NAME: 'zeppos_zeus_cli',
        PLATFORM_APP: 'com.huami.webapp'
    };
    var loginStorageKey = {
        accountToken: "".concat(accountPrefix, "token"),
        account: "".concat(accountPrefix, "account"),
        userid: "".concat(accountPrefix, "userid"),
        cname: "".concat(accountPrefix, "cname")
    };
    var analyticsKey = {
        id: "".concat(accountPrefix, "analyticsId")
    };
    return {
        zeusStorageInfo: zeusStorageInfo,
        accountPrefix: accountPrefix,
        account_env: account_env,
        LOGIN_URL: LOGIN_URL,
        ANALYTICS_HOST: ANALYTICS_HOST,
        loginConfig: loginConfig,
        analyticsKey: analyticsKey,
        loginStorageKey: loginStorageKey,
        simulatorStorageKey: exports.simulatorStorageKey
    };
};
exports.getLocalConfig = getLocalConfig;
