import { h } from "@stencil/core";
export class BpSdkQuoteRequestProductContainer {
    constructor() {
        this.product = undefined;
        this.useExternal = false;
        this.limits = [];
        this.vehicles = [];
        this.name = undefined;
    }
    resetState() { }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-quote-request-product-container');
        customElements.whenDefined('bp-sdk-external-quote-request-product-container').then(() => {
            this.useExternal = true;
        });
        this.onProductChange(this.product);
    }
    onProductChange(product) {
        var _a, _b;
        this.limits = this.getLimit(product);
        this.name = product === null || product === void 0 ? void 0 : product.name;
        this.vehicles = (_b = (_a = product === null || product === void 0 ? void 0 : product.coverage) === null || _a === void 0 ? void 0 : _a.vehicles) !== null && _b !== void 0 ? _b : [];
    }
    getLimit(product) {
        var _a, _b, _c, _d;
        return ((_d = (!!((_b = (_a = product === null || product === void 0 ? void 0 : product.coverage) === null || _a === void 0 ? void 0 : _a.limit_and_deductible) === null || _b === void 0 ? void 0 : _b.length)
            ? product.coverage.limit_and_deductible
            : (_c = product === null || product === void 0 ? void 0 : product.coverage) === null || _c === void 0 ? void 0 : _c.limit_and_deductible_default)) !== null && _d !== void 0 ? _d : []);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return h("bp-sdk-external-quote-request-product-container", { product: this.product });
    }
    renderInternal() {
        return (h("div", { class: "bp-sdk-quote-request-product-container__container" }, h("bp-sdk-quote-request-product", { limits: this.limits, name: this.name, vehicles: this.vehicles })));
    }
    static get is() { return "bp-sdk-quote-request-product-container"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-quote-request-product-container.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-quote-request-product-container.css"]
        };
    }
    static get properties() {
        return {
            "product": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IProduct",
                    "resolved": "IProduct",
                    "references": {
                        "IProduct": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IProduct"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Product information"
                }
            }
        };
    }
    static get states() {
        return {
            "useExternal": {},
            "limits": {},
            "vehicles": {},
            "name": {}
        };
    }
    static get watchers() {
        return [{
                "propName": "product",
                "methodName": "onProductChange"
            }];
    }
}
