import { r as registerInstance, h } from './index-77a9c9e7.js';
import { X as Xh, Y as Yh } from './index.esm.min-cd800f97.js';

const bpSdkQuoteRequestPremiumMonthlyCss = "";
const BpSdkQuoteRequestPremiumMonthlyStyle0 = bpSdkQuoteRequestPremiumMonthlyCss;

const BpSdkQuoteRequestPremiumMonthly = class {
    constructor(hostRef) {
        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 = Xh(annualPrice);
    }
    onDownpaymentChange(downpayment) {
        this._downpayment = Xh(downpayment);
    }
    onMonthlyPriceChange(monthlyPrice) {
        this._monthlyPrice = Xh(monthlyPrice);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-quote-request-premium-monthly", { annualPrice: this.annualPrice, downpayment: this.downpayment, installments: this.installments, monthlyPrice: this.monthlyPrice }));
    }
    renderInternal() {
        return (h("div", { class: "bp-sdk-quote-request-premium-monthly__container" }, h("div", null, h("p", { class: "bp-sdk-online-quote__price-main bp-sdk-quote__price-main" }, h("bp-sdk-quote-request-premium-payment", { period: "mo", price: this.monthlyPrice, showObelus: true })), h("p", { class: "bp-sdk-online-quote__price-disclaimers bp-sdk-quote__price-disclaimer" }, h("sup", null, "\u2020"), "Initial payment of ", this._downpayment, ", then ", this._monthlyPrice, " for ", this.installments, " months."), 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) {
        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 h("bp-sdk-external-quote-request-premium-payment", { period: this.period, price: this.price, showObelus: this.showObelus });
    }
    renderInternal() {
        return (h("div", { class: "bp-sdk-quote-request-premium-payment__container" }, h("div", { class: "bp-sdk-online-quote__price bp-sdk-quote__price" }, h("div", { class: "bp-sdk-online-quote__pride-usd bp-sdk-quote__price-usd" }, "$"), h("div", { class: "bp-sdk-online-quote__price-value bp-sdk-quote__price-value" }, this.priceDisplay(this.price)), h("div", { class: "bp-sdk-online-quote__price-period bp-sdk-quote__price-period" }, "/", this.period, this.showObelus && h("sup", null, "\u2020")))));
    }
    priceDisplay(price) {
        if (typeof price === 'number') {
            return 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) {
        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 (h("bp-sdk-external-quote-request-premium-term", { price: this.price, showTotalPremium: this.showTotalPremium, termLength: this.termLength, totalPremium: this.totalPremium }));
    }
    renderInternal() {
        return (h("div", { class: "bp-sdk-quote-request-premium-term__container" }, this.showTotalPremium && (h("div", { class: "bp-sdk-online-quote__price-total bp-sdk-quote__price-total" }, h("span", { class: "bp-sdk-online-quote__price-total-prefix bp-sdk-quote__price-total-prefix" }, "$"), h("span", { class: "bp-sdk-online-quote__price-total-number bp-sdk-quote__price-total-number" }, this.totalPremium), h("span", { class: "bp-sdk-online-quote__price-total-year bp-sdk-quote__price-total-suffix" }, "/year"))), !this.showTotalPremium && (h("p", { class: "bp-sdk-online-quote__price-main bp-sdk-quote__price-main" }, h("bp-sdk-quote-request-premium-payment", { price: this.price, period: this.termLength, showObelus: false })))));
    }
};
BpSdkQuoteRequestPremiumTerm.style = BpSdkQuoteRequestPremiumTermStyle0;

export { BpSdkQuoteRequestPremiumMonthly as bp_sdk_quote_request_premium_monthly, BpSdkQuoteRequestPremiumPayment as bp_sdk_quote_request_premium_payment, BpSdkQuoteRequestPremiumTerm as bp_sdk_quote_request_premium_term };
