'use strict';

exports.__esModule = true;

var _select = require('./select');

var _select2 = _interopRequireDefault(_select);

var _assert = require('./assert');

var _assert2 = _interopRequireDefault(_assert);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function copySelect() {
  var container = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
  var content = arguments[1];
  var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {
    return 0;
  };

  var succeed = true;
  var fakeEle = document.createElement('textarea');
  fakeEle.value = content;
  fakeEle.style.position = 'absolute';
  fakeEle.style.left = '-9999px';
  fakeEle.style.opacity = '0';
  container.appendChild(fakeEle);
  try {
    (0, _select2.default)(fakeEle);
    succeed = document.execCommand('copy');
  } catch (err) {
    succeed = false;
  }
  container.removeChild(fakeEle);
  _assert2.default.expect(succeed).warn("your browser doesn't allow access to the clipboard via scripts");
  callback(succeed);
}

exports.default = copySelect;