/**
 * 复制到剪切板
 *
 * @param {string} text 待复制的文本
 * @returns {Promise<void>}
 * @example
 *
 * ```ts
 * clipboardMp('stupid').then(() => {});
 * ```
 */
function clipboardWeb(text) {
  return new Promise(function (resolve, reject) {
    var pasteText = document.getElementById('#clipboard');
    pasteText === null || pasteText === void 0 ? void 0 : pasteText.remove();
    var textarea = document.createElement('textarea');
    textarea.id = '#clipboard';
    textarea.style.position = 'fixed';
    textarea.style.top = '-9999px';
    textarea.style.zIndex = '-9999';
    document.body.appendChild(textarea);
    textarea.value = "".concat(text);
    textarea.select();
    textarea.setSelectionRange(0, textarea.value.length);
    var result = document.execCommand('Copy', false);
    textarea.blur();
    if (result) {
      resolve();
    } else {
      reject();
    }
  });
}

export { clipboardWeb };
