import { p as proxyCustomElement, H, c as createEvent, h } from './p-CUAGH_8P.js';
import { d as defineCustomElement$1 } from './p-CO3KQG1e.js';

const verdocsDownloadDialogCss = "verdocs-download-dialog{-webkit-box-sizing:border-box;box-sizing:border-box;font-family:\"Inter\", \"Barlow\", sans-serif}verdocs-download-dialog .heading-container{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-align:center;align-items:center}verdocs-download-dialog .heading-container .polling-indicator{padding:0 24px;color:#9ca3af}verdocs-download-dialog .heading-container .polling-indicator .spinner{display:-ms-flexbox;display:flex;-webkit-animation:rotate 2s linear infinite;animation:rotate 2s linear infinite}verdocs-download-dialog .heading-container .polling-indicator .spinner svg{width:20px;height:20px}verdocs-download-dialog .content{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:15px;padding:0 24px 20px 24px}verdocs-download-dialog .download-option{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;padding:12px 15px;border:1px solid #e5e7eb;border-radius:6px;cursor:pointer;-webkit-transition:all 0.2s ease;transition:all 0.2s ease;gap:15px;background:white}verdocs-download-dialog .download-option.disabled{opacity:0.5;cursor:not-allowed}verdocs-download-dialog .download-option.disabled:hover{background-color:white;border-color:#e5e7eb}verdocs-download-dialog .download-option:hover{border-color:#654dcb;background-color:#f9fafb}verdocs-download-dialog .icon-container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:36px;height:36px;background-color:#f3f4f6;border-radius:50%;color:#4b5563;-ms-flex-negative:0;flex-shrink:0}verdocs-download-dialog .icon-container svg{width:18px;height:18px}verdocs-download-dialog .text-container{-ms-flex:1;flex:1}verdocs-download-dialog .text-container .label{font-weight:500;color:#111827;margin-bottom:2px}verdocs-download-dialog .text-container .description{font-size:13px;color:#6b7280}verdocs-download-dialog .status-indicator{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;gap:2px;font-size:11px;color:#9ca3af;min-width:50px}verdocs-download-dialog .status-indicator .signed{color:#10b981}verdocs-download-dialog .status-indicator .unsigned{color:#9ca3af}verdocs-download-dialog .status-indicator svg{width:16px;height:16px}verdocs-download-dialog .info-message{font-size:13px;color:#6b7280;font-style:italic;padding:0 4px}verdocs-download-dialog .arrow{color:#9ca3af}@-webkit-keyframes rotate{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes rotate{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}";

const DocumentIcon = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13 2H6C5.46957 2 4.96086 2.21071 4.58579 2.58579C4.21071 2.96086 4 3.46957 4 4V20C4 20.5304 4.21071 21.0391 4.58579 21.4142C4.96086 21.7893 5.46957 22 6 22H18C18.5304 22 19.0391 21.7893 19.4142 21.4142C19.7893 21.0391 20 20.5304 20 20V9L13 2Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M13 2V9H20" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
const CertificateIcon = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12 15C15.866 15 19 11.866 19 8C19 4.13401 15.866 1 12 1C8.13401 1 5 4.13401 5 8C5 11.866 8.13401 15 12 15Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M8.21 13.89L7 23L12 20L17 23L15.79 13.88" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
const ZipIcon = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 16V22H14V16" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 16H18" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M20 22H4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 10L12 16" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 12L12 16L16 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M4 16V4H20V16" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
const ChevronRight = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 18L15 12L9 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
const CheckIcon = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 6L9 17L4 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
const CircleIcon = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/></svg>`;
const RefreshIcon = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M23 4V10H17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M20.49 15A9 9 0 1 1 21.23 8" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
const VerdocsDownloadDialog = /*@__PURE__*/ proxyCustomElement(class VerdocsDownloadDialog extends H {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        this.next = createEvent(this, "next");
        this.exit = createEvent(this, "exit");
        /**
         * If true, the envelope is considered signed.
         */
        this.signed = false;
        /**
         * If true, we are currently polling the server for updates.
         */
        this.polling = false;
        /**
         * The list of documents in the envelope.
         */
        this.documents = [];
        /**
         * If true, the envelope has a certificate available for download.
         */
        this.hasCertificate = false;
    }
    handleOptionClick(action, documentId) {
        const hasCert = this.documents.some(d => d.type === 'certificate') || this.hasCertificate;
        const canDownloadCert = this.signed && hasCert;
        if ((action === 'certificate' || action === 'zip') && !canDownloadCert) {
            return;
        }
        this.next.emit({ action, documentId });
    }
    render() {
        const attachments = this.documents.filter(d => d.type === 'attachment').sort((a, b) => a.order - b.order);
        const hasCertificateDoc = this.documents.some(d => d.type === 'certificate') || this.hasCertificate;
        const canDownloadFinals = this.signed && hasCertificateDoc;
        return (h("verdocs-dialog", { key: '1f3eda2e32cb5bdcd409a99c23d1cf6a104f0848', onExit: () => this.exit.emit() }, h("div", { key: '5efe04c9ae05ae69b4127d299fce5e0a91dc8515', slot: "heading", class: "heading-container" }, h("h3", { key: '3e157afe6c10acf7de8465da84b8ac8b9fd43a27', style: { margin: '0', fontSize: '1.25rem', fontWeight: '600', padding: '16px 24px' } }, "Download"), this.polling && (h("div", { key: '5ad3a1fa22819106f8586a20bf3b53857122f9e4', class: "polling-indicator", title: "Checking for updates..." }, h("div", { key: '7bd6ff763a0dd044e50ec8c25c1b1cef0b3993c9', class: "spinner", innerHTML: RefreshIcon })))), h("div", { key: '256315253dbbc5da0bd8c8b2d2cbb1ce8d398da8', slot: "content", class: "content" }, attachments.length <= 2 &&
            attachments.map(doc => (h("div", { class: "download-option", onClick: () => this.handleOptionClick('document', doc.id) }, h("div", { class: "icon-container", innerHTML: DocumentIcon }), h("div", { class: "text-container" }, h("div", { class: "label" }, doc.name), h("div", { class: "description" }, this.signed ? 'Download the document' : 'Download the document')), h("div", { class: "status-indicator" }, this.signed ? h("div", { class: "signed", innerHTML: CheckIcon }) : h("div", { class: "unsigned", innerHTML: CircleIcon }), h("span", null, this.signed ? 'Signed' : 'In Progress')), h("div", { class: "arrow", innerHTML: ChevronRight })))), attachments.length > 2 && h("div", { key: 'a8b998b71ade27a3615689e3a87eb3d5a385133e', class: "info-message" }, "Multiple documents attached. Please use the ZIP option below to download all files."), h("div", { key: 'e9aaf13d0903f5c9490ff1b67fe4fd3b40774ad7', class: { 'download-option': true, 'disabled': !canDownloadFinals }, onClick: () => this.handleOptionClick('certificate'), title: !canDownloadFinals ? 'Certificate not yet available' : '' }, h("div", { key: '54afca498036b3146b650e9c763965b9ec473b51', class: "icon-container", innerHTML: CertificateIcon }), h("div", { key: 'bf6ffaaaae31cb5ee1416ab0a13df80e18285b9e', class: "text-container" }, h("div", { key: 'fb2606a0e127a073031f2c3828778c8ef71047e1', class: "label" }, "Certificate"), h("div", { key: '2dd12b55b37acc1de0f5ccb5d4d1d3635aeebdf7', class: "description" }, "Download the certificate")), h("div", { key: 'fcb974c2842e7f3651235513b97b2d6cb500b771', class: "arrow", innerHTML: ChevronRight })), h("div", { key: 'b9caabe10e57a1dea7c6015a5b769d236b973f63', class: { 'download-option': true, 'disabled': !canDownloadFinals }, onClick: () => this.handleOptionClick('zip'), title: !canDownloadFinals ? 'Certificate not yet available' : '' }, h("div", { key: 'ef7e94af475d82581e25782b405d729168aacae5', class: "icon-container", innerHTML: ZipIcon }), h("div", { key: 'd969b98d4db2630b59d27a7cd170fd829d22166e', class: "text-container" }, h("div", { key: 'd63270f5d483f8ecfa7b4d9612aa739d2b6d1853', class: "label" }, "All Files"), h("div", { key: 'f74e6585fb1e84b90c2a09366ebfd016a4765cc3', class: "description" }, "Download everything as a ZIP file")), h("div", { key: '9965c39b090e7908e532658633f711fbe821a4cb', class: "arrow", innerHTML: ChevronRight }))), h("div", { key: 'a5640b4a944db48063ee0d0cbab257cdc264e2b4', slot: "footer", style: { display: 'none' } })));
    }
    static get style() { return verdocsDownloadDialogCss; }
}, [256, "verdocs-download-dialog", {
        "signed": [4],
        "polling": [4],
        "documents": [16],
        "hasCertificate": [4, "has-certificate"]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["verdocs-download-dialog", "verdocs-dialog"];
    components.forEach(tagName => { switch (tagName) {
        case "verdocs-download-dialog":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, VerdocsDownloadDialog);
            }
            break;
        case "verdocs-dialog":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}

export { VerdocsDownloadDialog as V, defineCustomElement as d };
//# sourceMappingURL=p-DM-OXuAa.js.map

//# sourceMappingURL=p-DM-OXuAa.js.map