import { loadVConsole } from './v-console.mjs';
import '../dom/dom.mjs';
import '../loader/loader.mjs';
import '../loader/little-loader.mjs';
import './config.mjs';
import './plugin/delay.mjs';
import './plugin/env.mjs';
import './plugin/feedback.mjs';
import '../clipboard/clipboard-web.mjs';
import './plugin/msdk.mjs';
import './plugin/version.mjs';
import '@babel/runtime/helpers/toConsumableArray';
import './plugin/version-simple.mjs';
import '../time/time.mjs';

var V_CONSOLE_STORAGE = {
  KEY: 'SHOW_V_CONSOLE',
  VALUE: '1'
};
/**
 * vConsole 当前展示状态
 * @example
 * ```ts
 * import { V_CONSOLE_STATE, toggleVConsole } from 't-comm';
 *
 * console.log(V_CONSOLE_STATE.show); // false
 * toggleVConsole();
 * console.log(V_CONSOLE_STATE.show); // true
 * ```
 */
var V_CONSOLE_STATE = {
  show: false
};
function loadTheVConsole() {
  loadVConsole().then(function (instance) {
    window.vConsole = instance;
  });
}
/**
 * 展示 vConsole
 * @example
 * ```ts
 * showVConsole()
 * ```
 */
function showVConsole() {
  V_CONSOLE_STATE.show = true;
  localStorage.setItem(V_CONSOLE_STORAGE.KEY, V_CONSOLE_STORAGE.VALUE);
  loadTheVConsole();
}
/**
 * 关闭 vConsole
 * @example
 * ```ts
 * closeVConsole()
 * ```
 */
function closeVConsole() {
  var _a;
  localStorage.removeItem(V_CONSOLE_STORAGE.KEY);
  V_CONSOLE_STATE.show = false;
  (_a = window.vConsole) === null || _a === void 0 ? void 0 : _a.destroy();
}
/**
 * 切换展示 vConsole
 * @returns 是否展示
 * @example
 * ```ts
 * toggleVConsole()
 * ```
 */
function toggleVConsole() {
  if (V_CONSOLE_STATE.show) {
    closeVConsole();
  } else {
    showVConsole();
  }
  return V_CONSOLE_STATE.show;
}
/**
 * 检查 localStorage 设置，并展示vConsole
 * @example
 * ```ts
 * checkAndShowVConsole()
 * ```
 */
function checkAndShowVConsole() {
  var showVConsole = localStorage.getItem(V_CONSOLE_STORAGE.KEY) === V_CONSOLE_STORAGE.VALUE;
  if (showVConsole) {
    V_CONSOLE_STATE.show = true;
    loadTheVConsole();
  }
}

export { V_CONSOLE_STATE, checkAndShowVConsole, closeVConsole, showVConsole, toggleVConsole };
