'use strict';

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

const index = require('./index-292cc870.js');

const XCopy = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.content = undefined;
    }
    /**
     * Copy the content to clipboard
     *
     * @returns
     */
    copyContent() {
        if (!navigator.clipboard) {
            this.fallbackCopyTextToClipboard();
            return;
        }
        navigator.clipboard
            .writeText(this.content)
            .then(() => { }, err => {
            console.warn(err);
        });
    }
    /**
     * Fallback for copy text
     */
    fallbackCopyTextToClipboard() {
        const textArea = document.createElement("textarea");
        textArea.value = this.content;
        textArea.style.top = "0";
        textArea.style.left = "0";
        textArea.style.position = "fixed";
        document.body.appendChild(textArea);
        textArea.focus();
        textArea.select();
        try {
            document.execCommand('copy');
        }
        catch (err) {
            console.warn(err);
        }
        document.body.removeChild(textArea);
    }
    /**
     * Render element
     */
    render() {
        return index.h(index.Host, { key: '4878b251d70673186652db1a139dfaa42484e0fe', onClick: this.copyContent }, index.h("slot", { key: 'ec847c0c6ed3e915df80d3bf12976f150053b228' }));
    }
};

exports.x_copy = XCopy;
