import { h } from "@stencil/core";
export class BpSdkCoverageGroup {
    constructor() {
        this.questionGroup = undefined;
        this.useExternal = false;
    }
    resetState() { }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-coverage-group');
        customElements.whenDefined('bp-sdk-external-coverage-group').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return h("bp-sdk-external-coverage-group", { questionGroup: this.questionGroup });
    }
    renderAnswer(answer) {
        var _a;
        const nestedGroupToRender = (_a = this.questionGroup.nestedGroupsWithAnswers) === null || _a === void 0 ? void 0 : _a.get(answer.id);
        return [
            !nestedGroupToRender && h("bp-sdk-dynamic-input-redux-container", { answer: answer, id: `bp-sdk-question-group__${answer.question.id}` }),
            nestedGroupToRender && h("bp-sdk-question-group-container", { questionGroup: nestedGroupToRender }),
        ];
    }
    renderInternal() {
        var _a, _b, _c;
        return (h("div", { class: "bp-sdk-coverage-group__container" }, h("bp-sdk-question-group-label", { labelId: (_a = this.questionGroup) === null || _a === void 0 ? void 0 : _a.groupId, label: (_b = this.questionGroup) === null || _b === void 0 ? void 0 : _b.parentQuestionAnswer.question.text }), (_c = this.questionGroup) === null || _c === void 0 ? void 0 :
            _c.answers.map((answer) => this.renderAnswer(answer))));
    }
    static get is() { return "bp-sdk-coverage-group"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-coverage-group.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-coverage-group.css"]
        };
    }
    static get properties() {
        return {
            "questionGroup": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IMappedQuestionGroupAnswers",
                    "resolved": "IMappedQuestionGroupAnswers",
                    "references": {
                        "IMappedQuestionGroupAnswers": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IMappedQuestionGroupAnswers"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                }
            }
        };
    }
    static get states() {
        return {
            "useExternal": {}
        };
    }
}
