'use strict';

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

const index = require('./index-ceff47a0.js');
const index_esm_min = require('./index.esm.min-2e158fd8.js');

const bpSdkQuoteRequestPremiumMonthlyCss = "";
const BpSdkQuoteRequestPremiumMonthlyStyle0 = bpSdkQuoteRequestPremiumMonthlyCss;

const BpSdkQuoteRequestPremiumMonthly = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.annualPrice = undefined;
        this.downpayment = undefined;
        this.installments = undefined;
        this.monthlyPrice = undefined;
        this.useExternal = false;
        this._annualPrice = undefined;
        this._downpayment = undefined;
        this._monthlyPrice = undefined;
    }
    resetState() { }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-quote-request-premium-monthly');
        customElements.whenDefined('bp-sdk-external-quote-request-premium-monthly').then(() => {
            this.useExternal = true;
        });
        this.onMonthlyPriceChange(this.monthlyPrice);
        this.onAnnualPriceChange(this.annualPrice);
        this.onDownpaymentChange(this.downpayment);
    }
    onAnnualPriceChange(annualPrice) {
        this._annualPrice = index_esm_min.Xh(annualPrice);
    }
    onDownpaymentChange(downpayment) {
        this._downpayment = index_esm_min.Xh(downpayment);
    }
    onMonthlyPriceChange(monthlyPrice) {
        this._monthlyPrice = index_esm_min.Xh(monthlyPrice);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-quote-request-premium-monthly", { annualPrice: this.annualPrice, downpayment: this.downpayment, installments: this.installments, monthlyPrice: this.monthlyPrice }));
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-quote-request-premium-monthly__container" }, index.h("div", null, index.h("p", { class: "bp-sdk-online-quote__price-main bp-sdk-quote__price-main" }, index.h("bp-sdk-quote-request-premium-payment", { period: "mo", price: this.monthlyPrice, showObelus: true })), index.h("p", { class: "bp-sdk-online-quote__price-disclaimers bp-sdk-quote__price-disclaimer" }, index.h("sup", null, "\u2020"), "Initial payment of ", this._downpayment, ", then ", this._monthlyPrice, " for ", this.installments, " months."), index.h("p", { class: "bp-sdk-online-quote__price-alt bp-sdk-quote__price-alt" }, "Or ", this._annualPrice, "/yr"))));
    }
    static get watchers() { return {
        "annualPrice": ["onAnnualPriceChange"],
        "downpayment": ["onDownpaymentChange"],
        "monthlyPrice": ["onMonthlyPriceChange"]
    }; }
};
BpSdkQuoteRequestPremiumMonthly.style = BpSdkQuoteRequestPremiumMonthlyStyle0;

const bpSdkQuoteRequestPremiumPaymentCss = "";
const BpSdkQuoteRequestPremiumPaymentStyle0 = bpSdkQuoteRequestPremiumPaymentCss;

const BpSdkQuoteRequestPremiumPayment = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.period = undefined;
        this.price = undefined;
        this.showObelus = false;
        this.useExternal = false;
    }
    resetState() { }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-quote-request-premium-payment');
        customElements.whenDefined('bp-sdk-external-quote-request-premium-payment').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return index.h("bp-sdk-external-quote-request-premium-payment", { period: this.period, price: this.price, showObelus: this.showObelus });
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-quote-request-premium-payment__container" }, index.h("div", { class: "bp-sdk-online-quote__price bp-sdk-quote__price" }, index.h("div", { class: "bp-sdk-online-quote__pride-usd bp-sdk-quote__price-usd" }, "$"), index.h("div", { class: "bp-sdk-online-quote__price-value bp-sdk-quote__price-value" }, this.priceDisplay(this.price)), index.h("div", { class: "bp-sdk-online-quote__price-period bp-sdk-quote__price-period" }, "/", this.period, this.showObelus && index.h("sup", null, "\u2020")))));
    }
    priceDisplay(price) {
        if (typeof price === 'number') {
            return index_esm_min.Yh(price);
        }
        else if (!!price && price.includes('.')) {
            const convertedPrice = price.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
            return convertedPrice.split('.')[1].length === 2 ? convertedPrice : `${convertedPrice}0`;
        }
        return '0';
    }
};
BpSdkQuoteRequestPremiumPayment.style = BpSdkQuoteRequestPremiumPaymentStyle0;

const bpSdkQuoteRequestPremiumTermCss = "";
const BpSdkQuoteRequestPremiumTermStyle0 = bpSdkQuoteRequestPremiumTermCss;

const BpSdkQuoteRequestPremiumTerm = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.price = undefined;
        this.showTotalPremium = undefined;
        this.termLength = undefined;
        this.totalPremium = undefined;
        this.useExternal = false;
    }
    resetState() { }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-quote-request-premium-term');
        customElements.whenDefined('bp-sdk-external-quote-request-premium-term').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-quote-request-premium-term", { price: this.price, showTotalPremium: this.showTotalPremium, termLength: this.termLength, totalPremium: this.totalPremium }));
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-quote-request-premium-term__container" }, this.showTotalPremium && (index.h("div", { class: "bp-sdk-online-quote__price-total bp-sdk-quote__price-total" }, index.h("span", { class: "bp-sdk-online-quote__price-total-prefix bp-sdk-quote__price-total-prefix" }, "$"), index.h("span", { class: "bp-sdk-online-quote__price-total-number bp-sdk-quote__price-total-number" }, this.totalPremium), index.h("span", { class: "bp-sdk-online-quote__price-total-year bp-sdk-quote__price-total-suffix" }, "/year"))), !this.showTotalPremium && (index.h("p", { class: "bp-sdk-online-quote__price-main bp-sdk-quote__price-main" }, index.h("bp-sdk-quote-request-premium-payment", { price: this.price, period: this.termLength, showObelus: false })))));
    }
};
BpSdkQuoteRequestPremiumTerm.style = BpSdkQuoteRequestPremiumTermStyle0;

exports.bp_sdk_quote_request_premium_monthly = BpSdkQuoteRequestPremiumMonthly;
exports.bp_sdk_quote_request_premium_payment = BpSdkQuoteRequestPremiumPayment;
exports.bp_sdk_quote_request_premium_term = BpSdkQuoteRequestPremiumTerm;
