'use strict';

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

var clipboard_clipboardWeb = require('../../clipboard/clipboard-web.js');
var vConsole_config = require('../config.js');

function copyInfo(text) {
  clipboard_clipboardWeb.clipboardWeb(text).then(function () {
    alert('已复制，开去粘贴吧～');
  })["catch"](function () {
    alert('当前环境暂不支持复制，请长按选择复制～');
  });
}
function initFeedbackPlugin() {
  var uid = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  var loginPlugin = new VConsole.VConsolePlugin('feedback', '反馈');
  loginPlugin.on('init', function () {
    // this.list = [];
  });
  var url = window.location.href;
  var UA = navigator.userAgent;
  var _document = document,
    cookie = _document.cookie;
  var html = "<div class=\"".concat(vConsole_config.V_CONSOLE_DOM.WRAP, "\">\n<div class=\"").concat(vConsole_config.V_CONSOLE_DOM.LINE, "\">url\uFF1A").concat(url, "</div>\n<div class=\"").concat(vConsole_config.V_CONSOLE_DOM.LINE, "\">uid\uFF1A").concat(uid, "</div>\n<div class=\"").concat(vConsole_config.V_CONSOLE_DOM.LINE, "\">ua\uFF1A").concat(UA, "</div>\n<div class=\"").concat(vConsole_config.V_CONSOLE_DOM.LINE, "\">cookie\uFF1A").concat(cookie, "</div>\n  </div>\n  ");
  loginPlugin.on('renderTab', function (callback) {
    callback(html);
  });
  var btnList = [];
  btnList.push({
    name: '复制用户信息',
    global: false,
    onClick: function onClick() {
      var userInfo = {
        url: url,
        uid: uid,
        UA: UA,
        cookie: cookie
      };
      copyInfo(JSON.stringify(userInfo));
    }
  });
  loginPlugin.on('addTool', function (callback) {
    callback(btnList);
  });
  return loginPlugin;
}

exports.initFeedbackPlugin = initFeedbackPlugin;
