"use strict";

var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.copyDataToClipboard = void 0;
exports.executeOnTempElement = executeOnTempElement;
var _console = _interopRequireDefault(require("./console"));
var copyDataToClipboard = exports.copyDataToClipboard = function copyDataToClipboard(data) {
  return function (element) {
    element.value = data;
    element.select();
    element.focus();
    document.execCommand('copy');
    document.body.removeChild(element);
  };
};
function executeOnTempElement(callback) {
  var eTempInput = document.createElement('textarea');
  eTempInput.style.width = '1px';
  eTempInput.style.height = '1px';
  eTempInput.style.top = '0px';
  eTempInput.style.left = '0px';
  eTempInput.style.position = 'absolute';
  eTempInput.style.opacity = '0.0';
  document.body.appendChild(eTempInput);
  try {
    callback(eTempInput);
  } catch (err) {
    _console.default.warn('Browser does not support document.execCommand(\'copy\') for clipboard operations');
  }
}