import { h } from "@stencil/core";
export class BpSdkQuoteRequest {
    constructor() {
        this.actions = undefined;
        this.attachments = undefined;
        this.bindable = undefined;
        this.permittedToBind = undefined;
        this.carrier = undefined;
        this.products = [];
        this.quoteInfo = undefined;
        this.showLogo = true;
        this.showCustomLogo = false;
        this.customLogoBaseUrl = '';
        this.quoteStatus = undefined;
        this.quoteId = '';
        this.appFormId = '';
        this.translatedMessages = undefined;
        this.handleAction = undefined;
        this.handleBind = undefined;
        this.handleDownload = undefined;
        this.isAnnual = undefined;
        this.calls_to_action = undefined;
        this.satisfiesApplicationFormProductRequest = false;
        this.requestStatus = undefined;
        this.supplierName = undefined;
        this.supplierLogoUrl = undefined;
        this.supplierLogoUrlFull = undefined;
        this.supplierCode = undefined;
        this.parentQuoteRequestId = undefined;
        this.useExternal = false;
        this.termLength = 'year';
        this.price = undefined;
        this.totalPremium = undefined;
    }
    onCarrierChange(carrier, oldCarrier) {
        var _a;
        if (this.useExternal) {
            return;
        }
        if ((carrier === null || carrier === void 0 ? void 0 : carrier.id) !== (oldCarrier === null || oldCarrier === void 0 ? void 0 : oldCarrier.id)) {
            this.bpAnalyticsTrack.emit({
                eventName: 'Display',
                eventPayload: {
                    label: `${carrier.name}_RateReturned`,
                    value: 0,
                },
            });
            if (this.bindable) {
                this.bpAnalyticsTrack.emit({
                    eventName: 'Display',
                    eventPayload: {
                        label: 'OnlineBuy',
                        value: 0,
                        dataValue: ((_a = this.quoteInfo) === null || _a === void 0 ? void 0 : _a.annual_price) || 0,
                    },
                });
            }
        }
    }
    onQuoteStatusChange(quoteStatus) {
        var _a, _b;
        if (this.useExternal) {
            return;
        }
        if (quoteStatus === null || quoteStatus === void 0 ? void 0 : quoteStatus.recommended) {
            this.bpAnalyticsTrack.emit({
                eventName: 'Display',
                eventPayload: {
                    label: `Recommended Rate`,
                    value: ((_a = this.quoteInfo) === null || _a === void 0 ? void 0 : _a.annual_price) || '0',
                    dataValue: this.price || 'unknown',
                },
            });
            this.bpAnalyticsTrack.emit({
                eventName: 'Display',
                eventPayload: {
                    label: `Recommended Carrier`,
                    value: ((_b = this.carrier) === null || _b === void 0 ? void 0 : _b.name) || 'unknown',
                },
            });
        }
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-quote-request');
        customElements.whenDefined('bp-sdk-external-quote-request').then(() => {
            this.useExternal = true;
        });
        this.onCarrierChange(this.carrier, undefined);
        this.onQuoteStatusChange(this.quoteStatus);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-quote-request", { actions: this.actions, appFormId: this.appFormId, attachments: this.attachments, bindable: this.bindable, carrier: this.carrier, customLogoBaseUrl: this.customLogoBaseUrl, handleAction: this.handleAction, handleBind: this.handleBind, handleDownload: this.handleDownload, isAnnual: this.isAnnual, parentQuoteRequestId: this.parentQuoteRequestId, permittedToBind: this.permittedToBind, products: this.products, quoteId: this.quoteId, quoteInfo: this.quoteInfo, quoteStatus: this.quoteStatus, requestStatus: this.requestStatus, satisfiesApplicationFormProductRequest: this.satisfiesApplicationFormProductRequest, showCustomLogo: this.showCustomLogo, showLogo: this.showLogo, supplierCode: this.supplierCode, supplierLogoUrl: this.supplierLogoUrl, supplierLogoUrlFull: this.supplierLogoUrlFull, supplierName: this.supplierName, translatedMessages: this.translatedMessages }));
    }
    renderInternal() {
        return (h("div", { class: "bp-sdk-online-quote__container bp-sdk-quote__container" }, h("bp-sdk-quote-request-status-list-container", { quoteStatus: this.quoteStatus }), h("bp-sdk-quote-request-header-container", { carrier: this.carrier, customLogoBaseUrl: this.customLogoBaseUrl, showCustomLogo: this.showCustomLogo, showLogo: this.showLogo, quoteId: this.quoteId }), h("div", { class: "bp-sdk-online-quote__details bp-sdk-quote__details" }, h("div", { class: "bp-sdk-online-quote__pricing bp-sdk-quote__pricing" }, h("bp-sdk-quote-request-premium-container", { quoteInfo: this.quoteInfo }), this.renderBindContainer()), h("bp-sdk-quote-request-product-list-container", { products: this.products }), h("bp-sdk-quote-request-taxes-and-fees-container", { quoteInfo: this.quoteInfo }), this.renderBindContainer(), this.renderAttachmentContainer(), this.renderActionContainer())));
    }
    renderActionContainer() {
        var _a;
        if (((_a = this.actions) === null || _a === void 0 ? void 0 : _a.length) > 0) {
            return (h("div", { class: "bp-sdk-quote-actions__container" }, this.actions.map((action) => (h("button", { type: "button", onClick: () => this.handleAction(action, { id: this.quoteId, application_form_id: this.appFormId }) }, action.name)))));
        }
    }
    renderAttachmentContainer() {
        var _a;
        if (((_a = this.attachments) === null || _a === void 0 ? void 0 : _a.length) > 0) {
            return (h("div", { class: "bp-sdk-quote-attachments__container" }, this.attachments.map((attachment) => (h("button", { type: "button", onClick: () => this.handleDownload(attachment.id, attachment.filename) }, "Download ", attachment.filename)))));
        }
    }
    renderBindContainer() {
        return (h("bp-sdk-quote-request-bind-container", { appFormId: this.appFormId, carrier: this.carrier, handleBind: this.handleBind, isBindable: this.bindable, isPermittedToBind: this.permittedToBind, quoteId: this.quoteId, quoteInfo: this.quoteInfo }));
    }
    static get is() { return "bp-sdk-quote-request"; }
    static get originalStyleUrls() {
        return {
            "$": ["bp-sdk-quote-request.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-quote-request.css"]
        };
    }
    static get properties() {
        return {
            "actions": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IQuoteAction[]",
                    "resolved": "IQuoteAction[]",
                    "references": {
                        "IQuoteAction": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IQuoteAction"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Quote actions"
                }
            },
            "attachments": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IQuoteAttachment[]",
                    "resolved": "IQuoteAttachment[]",
                    "references": {
                        "IQuoteAttachment": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IQuoteAttachment"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Quote attachments"
                }
            },
            "bindable": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is bindable"
                },
                "attribute": "bindable",
                "reflect": false
            },
            "permittedToBind": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "User has permission to bind"
                },
                "attribute": "permitted-to-bind",
                "reflect": false
            },
            "carrier": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ICarrier",
                    "resolved": "ICarrier",
                    "references": {
                        "ICarrier": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::ICarrier"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Carrier"
                }
            },
            "products": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IProductDetail[]",
                    "resolved": "IProductDetail[]",
                    "references": {
                        "IProductDetail": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IProductDetail"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Product selection"
                },
                "defaultValue": "[]"
            },
            "quoteInfo": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IQuoteInfo",
                    "resolved": "IQuoteInfo",
                    "references": {
                        "IQuoteInfo": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IQuoteInfo"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Quote information"
                }
            },
            "showLogo": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Should show logo"
                },
                "attribute": "show-logo",
                "reflect": false,
                "defaultValue": "true"
            },
            "showCustomLogo": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Should show custom logo"
                },
                "attribute": "show-custom-logo",
                "reflect": false,
                "defaultValue": "false"
            },
            "customLogoBaseUrl": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Custom logo url"
                },
                "attribute": "custom-logo-base-url",
                "reflect": false,
                "defaultValue": "''"
            },
            "quoteStatus": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IQuoteStatus",
                    "resolved": "IQuoteStatus",
                    "references": {
                        "IQuoteStatus": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IQuoteStatus"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Quote status flags"
                }
            },
            "quoteId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Quote id"
                },
                "attribute": "quote-id",
                "reflect": false,
                "defaultValue": "''"
            },
            "appFormId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Application form id"
                },
                "attribute": "app-form-id",
                "reflect": false,
                "defaultValue": "''"
            },
            "translatedMessages": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ITranslatedMessage[]",
                    "resolved": "ITranslatedMessage[]",
                    "references": {
                        "ITranslatedMessage": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::ITranslatedMessage"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Translated messages"
                }
            },
            "handleAction": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "HandleActionBindFunction",
                    "resolved": "(action: IQuoteAction, quote: Pick<IQuoteRequest, \"id\" | \"application_form_id\">) => void",
                    "references": {
                        "HandleActionBindFunction": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::HandleActionBindFunction"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Function for running a quote action"
                }
            },
            "handleBind": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "HandleBindFunction",
                    "resolved": "(quoteId: string, appFormId: string, afterResponse?: (response: string) => void) => void",
                    "references": {
                        "HandleBindFunction": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::HandleBindFunction"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "quote bind function"
                }
            },
            "handleDownload": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "HandleAttachmentDownloadFunction",
                    "resolved": "(id: string, filename?: string) => void",
                    "references": {
                        "HandleAttachmentDownloadFunction": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::HandleAttachmentDownloadFunction"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Function for downloading an attachment"
                }
            },
            "isAnnual": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is Annual quote"
                },
                "attribute": "is-annual",
                "reflect": false
            },
            "calls_to_action": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ICallToAction[]",
                    "resolved": "ICallToAction[]",
                    "references": {
                        "ICallToAction": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::ICallToAction"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                }
            },
            "satisfiesApplicationFormProductRequest": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Does this quote contain all of the products that were selected in the application form"
                },
                "attribute": "satisfies-application-form-product-request",
                "reflect": false,
                "defaultValue": "false"
            },
            "requestStatus": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "QuoteRequestRequestTypes",
                    "resolved": "QuoteRequestRequestTypes.bound | QuoteRequestRequestTypes.completed | QuoteRequestRequestTypes.failed | QuoteRequestRequestTypes.in_progress | QuoteRequestRequestTypes.ineligible | QuoteRequestRequestTypes.referral | QuoteRequestRequestTypes.sent | QuoteRequestRequestTypes.timed_out | QuoteRequestRequestTypes.unsent",
                    "references": {
                        "QuoteRequestRequestTypes": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::QuoteRequestRequestTypes"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Quote request status"
                },
                "attribute": "request-status",
                "reflect": false
            },
            "supplierName": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Supplier name"
                },
                "attribute": "supplier-name",
                "reflect": false
            },
            "supplierLogoUrl": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Supplier logo url"
                },
                "attribute": "supplier-logo-url",
                "reflect": false
            },
            "supplierLogoUrlFull": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Supplier full size logo url"
                },
                "attribute": "supplier-logo-url-full",
                "reflect": false
            },
            "supplierCode": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Supplier code"
                },
                "attribute": "supplier-code",
                "reflect": false
            },
            "parentQuoteRequestId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Parent quote request ID will be populated if this is a wholesale quote"
                },
                "attribute": "parent-quote-request-id",
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "useExternal": {},
            "termLength": {},
            "price": {},
            "totalPremium": {}
        };
    }
    static get events() {
        return [{
                "method": "bpAnalyticsTrack",
                "name": "bpAnalyticsTrack",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "IAnalyticsTrackEventDetail",
                    "resolved": "IAnalyticsTrackEventDetail",
                    "references": {
                        "IAnalyticsTrackEventDetail": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IAnalyticsTrackEventDetail"
                        }
                    }
                }
            }];
    }
    static get watchers() {
        return [{
                "propName": "carrier",
                "methodName": "onCarrierChange"
            }, {
                "propName": "quoteStatus",
                "methodName": "onQuoteStatusChange"
            }];
    }
}
