import { Host, h } from "@stencil/core";
export class BbConnector {
    constructor() {
        /**
         * The root for mapping urls e.g. listing/id .
         */
        this.root = '#/';
        /**
         * Profile header layout .
         */
        this.profileHeader = 'overlay';
        /**
         * Collection header layout .
         */
        this.collectionHeader = 'overlay';
        /**
         * Collection list layout .
         */
        this.collectionList = 'overlay';
        this.collectionFilters = 'manufacturer,model';
        this.collectionLocationFilter = 'All Locations';
        this.collectionProfileFilter = 'All Profiles';
    }
    get id() {
        return this.path.split('/')[1];
    }
    get base() {
        return this.path.split('/')[0].replace(/s+$/, '');
    }
    get isPathValid() {
        return !!this.path;
    }
    get isBaseValid() {
        return ['listing', 'collection', 'profile'].includes(this.base);
    }
    get routerRoot() {
        // Remove the leading # and trailing slash when building router paths
        return this.root.replace(/^\#/, '').replace(/\/$/, '');
    }
    async linkClickHandler(event) {
        //console.log('Received the custom linkClickHandler event: ', event);
        event.preventDefault();
        this.history.push(this.routerRoot + '/' + event.detail.path);
    }
    render() {
        return (h(Host, null,
            h("stencil-router", { historyType: this.root.includes('#') ? 'hash' : 'browser' },
                this.isPathValid && this.base == 'listing' && h("stencil-route-switch", null,
                    h("stencil-route", { url: [this.routerRoot, this.routerRoot + '/'], exact: true, routeRender: (props) => { this.history = props.history; return h("bb-listing", { listingPath: this.id, root: this.root }); } }),
                    h("stencil-route", { url: this.routerRoot + '/updates/:updateId', exact: true, routeRender: (props) => (h("div", null,
                            "Listing Update ",
                            this.path,
                            " ",
                            props.match.params.updateId)) }),
                    h("stencil-route", { routeRender: () => (h("div", null, "404 - Listing")) })),
                this.isPathValid && this.base == 'profile' && h("stencil-route-switch", null,
                    h("stencil-route", { url: [this.routerRoot, this.routerRoot + '/'], exact: true, routeRender: (props) => { this.history = props.history; return h("bb-profile", { profilePath: this.id, root: this.root, profileHeader: this.profileHeader }); } }),
                    h("stencil-route", { url: this.routerRoot + '/listings/:listingId', exact: true, routeRender: (props) => { this.history = props.history; return h("bb-listing", { listingPath: props.match.params.listingId, root: this.root }); } }),
                    h("stencil-route", { url: this.routerRoot + '/collections/:collectionId', exact: true, routeRender: (props) => {
                            this.history = props.history;
                            return h("bb-collection", { collectionPath: props.match.params.collectionId, collectionHeader: this.collectionHeader, collectionList: this.collectionList, collectionFilters: this.collectionFilters, collectionLocationFilter: this.collectionLocationFilter, collectionProfileFilter: this.collectionProfileFilter, root: this.root });
                        } }),
                    h("stencil-route", { routeRender: () => (h("div", null, "404 - Profile")) })),
                this.isPathValid && this.base == 'collection' && h("stencil-route-switch", null,
                    h("stencil-route", { url: [this.routerRoot, this.routerRoot + '/'], exact: true, routeRender: (props) => {
                            this.history = props.history;
                            return h("bb-collection", { collectionPath: this.id, collectionHeader: this.collectionHeader, collectionList: this.collectionList, collectionFilters: this.collectionFilters, collectionLocationFilter: this.collectionLocationFilter, collectionProfileFilter: this.collectionProfileFilter, root: this.root });
                        } }),
                    h("stencil-route", { url: this.routerRoot + '/listings/:listingId', exact: true, routeRender: (props) => {
                            return h("bb-listing", { key: props.match.params.listingId, listingPath: props.match.params.listingId, root: this.root });
                        } }),
                    h("stencil-route", { routeRender: () => (h("div", null, "404 - Collection")) })),
                !this.isPathValid || !this.isBaseValid && h("stencil-route-switch", null,
                    h("stencil-route", { routeRender: () => (h("div", null, "400")) })))));
    }
    static get is() { return "bb-connector"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() { return {
        "$": ["bb-connector.css"]
    }; }
    static get styleUrls() { return {
        "$": ["bb-connector.css"]
    }; }
    static get properties() { return {
        "path": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": "The path of the component you want to display."
            },
            "attribute": "path",
            "reflect": false
        },
        "root": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": "The root for mapping urls e.g. listing/id ."
            },
            "attribute": "root",
            "reflect": false,
            "defaultValue": "'#/'"
        },
        "profileHeader": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "'none' | 'overlay' | 'image'",
                "resolved": "\"image\" | \"none\" | \"overlay\"",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": "Profile header layout ."
            },
            "attribute": "profile-header",
            "reflect": false,
            "defaultValue": "'overlay'"
        },
        "collectionHeader": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "'none' | 'overlay' | 'image'",
                "resolved": "\"image\" | \"none\" | \"overlay\"",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": "Collection header layout ."
            },
            "attribute": "collection-header",
            "reflect": false,
            "defaultValue": "'overlay'"
        },
        "collectionList": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "'card' | 'overlay'",
                "resolved": "\"card\" | \"overlay\"",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": "Collection list layout ."
            },
            "attribute": "collection-list",
            "reflect": false,
            "defaultValue": "'overlay'"
        },
        "collectionFilters": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "collection-filters",
            "reflect": false,
            "defaultValue": "'manufacturer,model'"
        },
        "collectionLocationFilter": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "collection-location-filter",
            "reflect": false,
            "defaultValue": "'All Locations'"
        },
        "collectionProfileFilter": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "collection-profile-filter",
            "reflect": false,
            "defaultValue": "'All Profiles'"
        }
    }; }
    static get listeners() { return [{
            "name": "linkClick",
            "method": "linkClickHandler",
            "target": undefined,
            "capture": false,
            "passive": false
        }]; }
}
