import { h } from "@stencil/core";
import store from "../../services/redux-store.service";
export class BpSdkFilterContainer {
    constructor() {
        this.handleSubscriptions = () => {
            this.storeUnsubscribe && this.storeUnsubscribe();
            this.storeUnsubscribe = store.mapStateToProps(this, this.mapStateToProps);
        };
        this.mapStateToProps = (state) => {
            return {
                isHidden: !!(this.filter && this.filter(state)),
            };
        };
        this.filter = undefined;
        this.isHidden = false;
        this.useExternal = false;
    }
    resetState() { }
    onFilterChange() {
        this.handleSubscriptions();
    }
    connectedCallback() {
        this.resetState();
        this.handleSubscriptions();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-filter-container');
        customElements.whenDefined('bp-sdk-external-filter-container').then(() => {
            this.useExternal = true;
        });
        this.onFilterChange();
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return h("bp-sdk-external-filter-container", { filter: this.filter, isHidden: this.isHidden });
    }
    renderInternal() {
        return (!this.isHidden && (h("div", { class: "bp-sdk-filter-container__container" }, h("host", null))));
    }
    static get is() { return "bp-sdk-filter-container"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-filter-container.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-filter-container.css"]
        };
    }
    static get properties() {
        return {
            "filter": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "(state: BpSdkStore) => boolean",
                    "resolved": "(state: { application: CombinedState<{ form: IFormState; enrollments: IAppFormEnrollment[]; choices: IChoiceState; errors: IErrorState; pendingProcesses: IApplicationFormProcesses[]; progress: IProgressState; questionSets: IQuestionSetState; quotes: IQuotesState[]; quoteBind: IQuoteBindState; carriersProducts: ICarriersProductState[]; refilters: IRefilterState; }>; auth: IAuthState; queues: IQueueState; config: IConfigState; notifications: INotificationState[]; viewState: CombinedState<{ vehicleOptions: CombinedState<{ configurations: IQuestionGroupState<IVehicleConfigurationOptions>; makes: IQuestionGroupState<IVehicleMakeOptions>; models: IQuestionGroupState<IVehicleModelOptions>; selection: IQuestionGroupState<IVehicleSelection>; vin: IQuestionGroupState<IVehicleVinOptions>; years: IQuestionGroupState<IVehicleYearOptions>; }>; features: IFeatureState; quotes: IViewStateQuotesState; addressValidation: IAddressValidationState; }>; status: CombinedState<{ remote: CombinedState<{ vehicles: CombinedState<{ configurations: IResourceMap; makes: IResourceMap; models: IResourceMap; selection: IResourceMap; vins: IResourceMap; years: IResourceMap; }>; answers: IResourceMapState; application: IApplicationResourceState; bindQuotes: IResourceMap; carriersProducts: IQuoteResourceState; choices: IResourceMap; questionPools: IResourceMapState; questionSets: IResourceMapState; quotes: IQuoteResourceState; refilters: IResourceMap; }>; local: ILocalState; }>; }) => boolean",
                    "references": {
                        "BpSdkStore": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-redux",
                            "id": "../sdk-redux/dist/types.d.ts::BpSdkStore"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                }
            },
            "isHidden": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "is-hidden",
                "reflect": true,
                "defaultValue": "false"
            }
        };
    }
    static get states() {
        return {
            "useExternal": {}
        };
    }
    static get watchers() {
        return [{
                "propName": "filter",
                "methodName": "onFilterChange"
            }];
    }
}
