import { r as registerInstance, c as createEvent, h, H as Host } from './index-BIRwgFLv.js';
import { VerdocsEndpoint } from '@verdocs/js-sdk';
import { u as unicodeNBSP } from './Icons-COC8ZzcY.js';

const verdocsFileChooserCss = "verdocs-file-chooser{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff;font-family:var(--verdocs-primary-font, \"Inter\", \"Barlow\", sans-serif)}verdocs-file-chooser .upload-box{text-align:center;-webkit-box-sizing:border-box;box-sizing:border-box;padding:40px 15px;color:rgba(0, 0, 0, 0.54)}verdocs-file-chooser .upload-box svg{width:64px;height:64px;fill:#5c6575}verdocs-file-chooser .selected-filename{font-size:20px;font-weight:bold;overflow-wrap:anywhere}verdocs-file-chooser .or-prefer{height:20px;margin:20px 0;font-size:16px}";

const VerdocsFileChooser = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.fileSelected = createEvent(this, "fileSelected");
        /**
         * The endpoint to use to communicate with Verdocs. If not set, the default endpoint will be used.
         */
        this.endpoint = VerdocsEndpoint.getDefault();
    }
    handleFileChanged(e) {
        var _a, _b;
        this.file = ((_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0]) || null;
        (_b = this.fileSelected) === null || _b === void 0 ? void 0 : _b.emit({ file: this.file });
        console.debug('[CHOOSER] Selected file', this.file);
    }
    handleSelectFile(e) {
        var _a, _b;
        e.stopPropagation();
        this.file = null;
        (_a = this.fileSelected) === null || _a === void 0 ? void 0 : _a.emit({ file: null });
        (_b = document.getElementById('verdocs-file-chooser')) === null || _b === void 0 ? void 0 : _b.click();
    }
    render() {
        const buttonlabel = this.file ? 'Select a different file' : 'Select a file from your computer';
        return (h(Host, { key: '9bbcded830636b89e0b47dd545c15117c5b9f8b8' }, h("input", { key: '0d8fb69380eb9391ad2e704e07abf29483ed7a01', type: "file", multiple: true, id: "verdocs-file-chooser", accept: "application/pdf,.pdf,.doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", style: { display: 'none' }, onChange: e => this.handleFileChanged(e) }), h("div", { key: 'ac5d2a127e5653ed80effd71e7d5b41024b931a7', class: "upload-box" }, h("div", { key: 'bfe87d0804272452b31461e4eb714e9336157394', class: "selected-filename" }, this.file ? this.file.name : 'Drag a file here'), h("div", { key: '0999c21ef1c212435cbabd7eca81f8a7463055fe', class: "or-prefer" }, this.file ? unicodeNBSP : 'Or, if you prefer...'), h("verdocs-button", { key: 'd0b299a80d0cede99f92b06ab512053de0441011', label: buttonlabel, size: "small", onClick: e => this.handleSelectFile(e) }))));
    }
};
VerdocsFileChooser.style = verdocsFileChooserCss;

const verdocsProgressBarCss = "verdocs-progress-bar{font-family:\"Inter\", \"Barlow\", sans-serif;width:100%;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-progress-bar .labels{display:-ms-flexbox;display:flex;margin:0 0 8px 0;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between}verdocs-progress-bar .labels .label{display:-ms-flexbox;display:flex;font-size:14px;font-weight:600;margin-right:8px;color:#33364b}verdocs-progress-bar .bar{display:-ms-flexbox;display:flex;-ms-flex:0 0 10px;flex:0 0 10px;border-radius:5px;background-color:#cccccc}verdocs-progress-bar .bar .slider{display:-ms-flexbox;display:flex;border-radius:5px;background-color:#55bc81}";

const VerdocsProgressBar = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        /**
         * Optional label to display above the bar
         */
        this.label = '';
        /**
         * If true, the progress percentage will be displayed above the bar.
         */
        this.showPercent = false;
        /**
         * The current progress value (0-100)
         */
        this.percent = 0;
    }
    render() {
        const widthPercent = Math.ceil((100 * Math.min(this.percent, 100)) / 100);
        console.log('Rendering progress bar', { widthPercent, label: this.label, showPercent: this.showPercent, percent: this.percent });
        return (h(Host, { key: 'deb87ba92583c69d4257c9b0ac2e288c5968dcec' }, h("div", { key: '6122cb2a4629aaff872b7aaa78d6c48e72a1c4a6', class: "labels" }, this.label && h("div", { key: '39d984b137bfccf228a397baf25eb94d918ba5a1', class: "label" }, this.label), this.showPercent && h("div", { key: '9e5e8d5b01fac6ad5ee539ed6ed979399e035798', class: "label" }, this.percent, "%")), h("div", { key: '5a2d126da3607ab523a795139741c3490cf0b27b', class: "bar" }, h("div", { key: 'f58d38908e994413826c740efc343e962ec4b50a', class: "slider", style: { width: `${widthPercent}%` } }))));
    }
};
VerdocsProgressBar.style = verdocsProgressBarCss;

export { VerdocsFileChooser as verdocs_file_chooser, VerdocsProgressBar as verdocs_progress_bar };
//# sourceMappingURL=verdocs-file-chooser.verdocs-progress-bar.entry.js.map
