'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-ceff47a0.js');
const reduxStore_service = require('./redux-store.service-10b7725a.js');
require('./index.esm.min-f57d151c.js');

const bpSdkFilterContainerCss = "";
const BpSdkFilterContainerStyle0 = bpSdkFilterContainerCss;

const BpSdkFilterContainer = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.handleSubscriptions = () => {
            this.storeUnsubscribe && this.storeUnsubscribe();
            this.storeUnsubscribe = reduxStore_service.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 index.h("bp-sdk-external-filter-container", { filter: this.filter, isHidden: this.isHidden });
    }
    renderInternal() {
        return (!this.isHidden && (index.h("div", { class: "bp-sdk-filter-container__container" }, index.h("host", null))));
    }
    static get watchers() { return {
        "filter": ["onFilterChange"]
    }; }
};
BpSdkFilterContainer.style = BpSdkFilterContainerStyle0;

exports.bp_sdk_filter_container = BpSdkFilterContainer;
