'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var time_time = require('../../time/time.js');
var vConsole_config = require('../config.js');

function renderVersion(callback) {
  // @ts-ignore
  var info = window.igameVersion;
  var innerHtml = '';
  if (info === null || info === void 0 ? void 0 : info.version) {
    var time = "".concat(time_time.dateFormat(new Date(+info.version), 'yyyy-MM-dd hh:mm:ss'));
    innerHtml = "\n  <div class=\"".concat(vConsole_config.V_CONSOLE_DOM.LINE, "\">\u6784\u5EFA\u65F6\u95F4\uFF1A").concat(time || '', "</div>\n  <div class=\"").concat(vConsole_config.V_CONSOLE_DOM.LINE, "\">\u6784\u5EFA\u4F5C\u8005\uFF1A").concat(info.author || '', "</div>\n  ");
  } else {
    innerHtml = " <div class=\"".concat(vConsole_config.V_CONSOLE_DOM.LINE, "\">\u65E0\u6784\u5EFA\u4FE1\u606F</div>");
  }
  callback("<div class=\"".concat(vConsole_config.V_CONSOLE_DOM.WRAP, "\">").concat(innerHtml, "</div>"));
}
function initVersionSimplePlugin() {
  var plugin = new VConsole.VConsolePlugin(vConsole_config.V_CONSOLE_DOM.PLUGIN_SIMPLE_VERSION_NAME, '版本信息');
  var callback = function callback(html) {
    var dom = document.getElementById("".concat(vConsole_config.V_CONSOLE_DOM.PLUGIN_NAME_PREFIX).concat(vConsole_config.V_CONSOLE_DOM.PLUGIN_SIMPLE_VERSION_NAME));
    if (dom) {
      dom.innerHTML = html;
    }
  };
  // 先加载version.js，种上IGameVersion对象
  plugin.on('renderTab', function (callback) {
    renderVersion(callback);
  });
  plugin.on('showConsole', function () {
    renderVersion(callback);
  });
  plugin.on('show', function () {
    renderVersion(callback);
  });
  return plugin;
}

exports.initVersionSimplePlugin = initVersionSimplePlugin;
