import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-AiOs8RvA.js';
import { verifySigner } from '@verdocs/js-sdk';
import { D as DefaultEndpoint } from './p-C_Xku1v2.js';
import { d as defineCustomElement$1 } from './p-DMVmShTi.js';

const verdocsOtpDialogCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-otp-dialog{font-family:\"Inter\", \"Barlow\", sans-serif;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-otp-dialog div{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-otp-dialog .background-overlay{position:fixed;z-index:10000;top:0;left:0;right:0;bottom:0;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;background:rgba(0, 0, 0, 0.4980392157)}verdocs-otp-dialog .dialog{width:440px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;border-radius:4px;overflow:hidden;background:#fff;padding:16px;gap:10px;-webkit-box-shadow:3px 3px 5px 1px rgba(40, 40, 40, 0.4);box-shadow:3px 3px 5px 1px rgba(40, 40, 40, 0.4)}verdocs-otp-dialog .heading{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;font-size:20px;font-weight:500}verdocs-otp-dialog .step{margin-left:6px;color:#666}verdocs-otp-dialog .help-box{background-color:#707ae5;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;padding:14px;-ms-flex-align:center;align-items:center;color:white}verdocs-otp-dialog .help-details{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;margin-left:15px;font-size:14px}verdocs-otp-dialog .help-icon{width:40px;height:40px}verdocs-otp-dialog .help-title{font-weight:600;margin-bottom:4px}verdocs-otp-dialog .help-text{font-weight:400}verdocs-otp-dialog .input{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;gap:10px;-ms-flex-align:center;align-items:center;margin:16px 0 32px}verdocs-otp-dialog .input label{-ms-flex:0;flex:0;line-height:10px;font-weight:500;white-space:nowrap}verdocs-otp-dialog .input input{-ms-flex:1;flex:1;padding:5px 8px;border-radius:3px;border:1px solid #cccccc}verdocs-otp-dialog .field{gap:10px;margin:0;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;max-width:100%}verdocs-otp-dialog .field .required{color:red;position:relative;top:-0.5em;font-size:80%}verdocs-otp-dialog .field label{-ms-flex:0 0 120px;flex:0 0 120px;font-weight:500;line-height:10px;text-align:right;white-space:nowrap}verdocs-otp-dialog .field verdocs-date-input{width:40%;-ms-flex-positive:1;flex-grow:1}verdocs-otp-dialog .field verdocs-date-input input{width:100%;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-otp-dialog .field input{width:40%;-ms-flex-positive:1;flex-grow:1;padding:5px 8px;border-radius:3px;border:1px solid #cccccc}verdocs-otp-dialog .choices{display:grid;gap:15px;grid-template-columns:repeat(auto-fill, minmax(100px, 1fr));margin:0 0 15px 0}verdocs-otp-dialog .choice{border:1px solid #707ae5;border-radius:5px;display:-ms-flexbox;display:flex;height:60px;font-size:14px;padding:0 5px;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;text-align:center;color:#5c6575;cursor:pointer}verdocs-otp-dialog .choice.selected{background-color:#707ae5;color:#ffffff}verdocs-otp-dialog .buttons{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-otp-dialog .buttons verdocs-button{margin-left:16px}";

const QuestionIcon = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 0C8.95313 0 0 8.95313 0 20C0 31.0469 8.95313 40 20 40C31.0469 40 40 31.0469 40 20C40 8.95313 31.0469 0 20 0ZM20 36.25C11.0391 36.25 3.75 28.9602 3.75 20C3.75 11.0398 11.0391 3.75 20 3.75C28.9609 3.75 36.25 11.0398 36.25 20C36.25 28.9602 28.9609 36.25 20 36.25Z" fill="white"/><path d="M20 26.25C18.5938 26.25 17.5 27.3438 17.5 28.75C17.5 30.1562 18.5234 31.25 20 31.25C21.3359 31.25 22.5 30.1562 22.5 28.75C22.5 27.3438 21.3359 26.25 20 26.25ZM22.5859 10H18.5938C15.5469 10 13.125 12.4219 13.125 15.4688C13.125 16.4844 13.9844 17.3438 15 17.3438C16.0156 17.3438 16.875 16.4844 16.875 15.4688C16.875 14.5312 17.5859 13.75 18.5234 13.75H22.5156C23.5234 13.75 24.375 14.5312 24.375 15.4688C24.375 16.0938 24.0625 16.5703 23.5156 16.8828L19.0625 19.6094C18.4375 20 18.125 20.625 18.125 21.25V22.5C18.125 23.5156 18.9844 24.375 20 24.375C21.0156 24.375 21.875 23.5156 21.875 22.5V22.3438L25.3984 20.1562C27.0391 19.1406 28.0547 17.3438 28.0547 15.4688C28.125 12.4219 25.7031 10 22.5859 10Z" fill="#E7E7E7"/></svg>`;
const VerdocsOtpDialog = /*@__PURE__*/ proxyCustomElement(class VerdocsOtpDialog extends H {
    constructor() {
        super();
        this.__registerHost();
        this.exit = createEvent(this, "exit");
        this.next = createEvent(this, "next");
        this.resendTimeout = null;
        /**
         * The endpoint to use to communicate with Verdocs. If not set, the default endpoint will be used.
         */
        this.endpoint = DefaultEndpoint;
        /**
         * The type of dialog to display. Three modes are supported.
         */
        this.method = 'email';
        /**
         * For identity confirmation, the current recipient details.
         */
        this.recipient = null;
        this.resendDisabled = true;
        this.response = '';
    }
    componentDidLoad() {
        this.startResendTimeout();
        // Give the parent time to finish what it's doing.
        setTimeout(() => {
            verifySigner(this.endpoint, { auth_method: this.method, code: '', resend: true })
                .then(r => {
                console.log('Resend result', r);
                this.response = '';
            })
                .catch(e => console.log('Error resending code', e));
        }, 1000);
    }
    disconnectedCallback() {
        if (this.resendTimeout) {
            clearTimeout(this.resendTimeout);
            this.resendTimeout = null;
        }
    }
    handleCancel() {
        this.exit.emit();
    }
    // We need a separate event handler for clicking the background because it can receive events "through" other child components
    handleDismiss(e) {
        if (e.target.class === 'background-overlay') {
            e.preventDefault();
            this.handleCancel();
        }
    }
    startResendTimeout() {
        this.resendDisabled = true;
        if (this.resendTimeout) {
            clearTimeout(this.resendTimeout);
        }
        this.resendTimeout = setTimeout(() => {
            this.resendDisabled = false;
        }, 30000);
    }
    handleResend() {
        this.startResendTimeout();
        verifySigner(this.endpoint, { auth_method: this.method, code: '', resend: true })
            .then(r => {
            console.log('Resend result', r);
            this.response = '';
            window.alert('A new code has been sent.');
        })
            .catch(e => console.log('Error resending code', e));
    }
    handleSubmit() {
        this.startResendTimeout();
        verifySigner(this.endpoint, { auth_method: this.method, code: this.response })
            .then(response => {
            console.log('Verification completed', response);
            this.next.emit({ response });
            window.alert('Thank you. Your verification was successful.');
        })
            .catch(e => {
            window.alert('Invalid verification code. Please try again.');
            console.log('Invalid code', e);
        });
        this.response = '';
    }
    render() {
        return (h(Host, { key: 'b264293071f7bef8b21a8a271cefc361b1a9988c' }, h("div", { key: '1a0e3b861dff92f5e73980237f3c682bf5864e4a', class: "background-overlay", onClick: e => this.handleDismiss(e) }, h("div", { key: '9530b8a2aa6bf5463af6a581e922421db5451a01', class: "dialog" }, h("div", { key: '904c74579299b714e5bfdd3c9640b62829f4fe75', class: "heading" }, "Verification Required"), h("div", { key: '4c47e33939d2683c58fec11bff9f527bff85b456', class: "help-box" }, h("div", { key: '7318779bce06bf3b6ce8a2b5823124444a76072d', class: "help-icon", innerHTML: QuestionIcon }), h("div", { key: 'e9bef6188ac6046720ed2a6388256f2afe3f0176', class: "help-details" }, h("div", { key: '8407632733f4c6284b440dea8ca88f498689c0d9', class: "help-title" }, "Please verify your email address"), h("div", { key: 'ff4098afa88eb804d821056786a47c6dd9237da4', class: "help-text" }, "Check your email for a one-time code, and enter it below."))), h("div", { key: '242fbeef76e8bf1e06b8525670acfd97b93254a7', class: "input" }, h("label", { key: '252fef5d5e6ba5e2dac59d4180acfe58fb8c7c58', htmlFor: "verdocs-otp-input" }, "Code:"), h("input", { key: '85f03f11f6dd47a734cc10a3aac97cd6d4c901ff', type: "text", id: "verdocs-otp-input", name: "verdocs-otp-input", placeholder: "Enter your one-time code...", value: this.response, onInput: (e) => (this.response = e.target.value) })), h("div", { key: '7d9c09905b2c0279350113a937427ec0e14f3cff', class: "buttons" }, h("verdocs-button", { key: 'cdb7f5906897c90c4fe5b0f1aeb2a7b9244136ce', label: "Cancel", variant: "outline", onClick: () => this.handleCancel() }), h("verdocs-button", { key: '679184fd5eac96a8240e67e9b3264076b2a8ae14', label: 'Resend', onClick: () => this.handleResend(), disabled: this.resendDisabled }), h("verdocs-button", { key: '24ec1dbf72f580818dade1f39bdbd5723af403a5', label: 'Submit', onClick: () => this.handleSubmit(), disabled: !this.response }))))));
    }
    static get style() { return verdocsOtpDialogCss; }
}, [0, "verdocs-otp-dialog", {
        "endpoint": [1040],
        "method": [1],
        "recipient": [16],
        "resendDisabled": [32],
        "response": [32]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["verdocs-otp-dialog", "verdocs-button"];
    components.forEach(tagName => { switch (tagName) {
        case "verdocs-otp-dialog":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, VerdocsOtpDialog);
            }
            break;
        case "verdocs-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}

export { VerdocsOtpDialog as V, defineCustomElement as d };
//# sourceMappingURL=p-wjmeDrjo.js.map

//# sourceMappingURL=p-wjmeDrjo.js.map