import { Host, h, } from "@stencil/core";
import { DEVICE_SIZES, getBrandForegroundAppearance, } from "../../utils/helpers";
export class FooterLink {
    constructor() {
        this.deviceSize = DEVICE_SIZES.XL;
        this.footerConfig = { small: false, grouped: false };
        this.foregroundColor = getBrandForegroundAppearance();
        /**
         * If `true`, the user can save the linked URL instead of navigating to it.
         */
        this.download = false;
    }
    componentWillLoad() {
        this.footerConfig = this.inferConfig(this.el);
    }
    footerResizeHandler() {
        this.footerConfig = this.inferConfig(this.el);
    }
    footerBrandChangeHandler(ev) {
        this.foregroundColor = ev.detail.mode;
    }
    inferConfig(e) {
        if (e.parentElement !== null) {
            if (e.parentElement.classList.contains("ic-footer")) {
                return {
                    small: e.parentElement.classList.contains("ic-footer-small"),
                    grouped: e.parentElement.classList.contains("ic-footer-grouped"),
                };
            }
            else {
                return this.inferConfig(e.parentElement);
            }
        }
        else {
            return { small: false, grouped: false };
        }
    }
    render() {
        const { footerConfig, href, hreflang, referrerpolicy, rel, target, download, } = this;
        const { small, grouped } = footerConfig;
        const isLogoLink = !!this.el.closest("div[slot='logo']");
        return (h(Host, { key: '7488851004e3af24c0b0e1d9f9ccaf0d55ae5990', class: {
                "footer-link": true,
                [`footer-link-${grouped ? "grouped" : "ungrouped"}-${small ? "small" : "sparse"}`]: true,
                [`footer-link-${this.foregroundColor}`]: true,
                "footer-logo-link": isLogoLink,
            }, role: "listitem" }, h("ic-link", { key: 'e388559e01bc73c013b7493dd2c315f730beb4b8', class: "footer-link", href: href, hreflang: hreflang, referrerpolicy: referrerpolicy, rel: rel, download: download !== false ? download : undefined, target: target }, h("slot", { key: '013a86414ccca833cd52a4164c93bdf9ef040a4f' }))));
    }
    static get is() { return "ic-footer-link"; }
    static get encapsulation() { return "shadow"; }
    static get delegatesFocus() { return true; }
    static get originalStyleUrls() {
        return {
            "$": ["ic-footer-link.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["ic-footer-link.css"]
        };
    }
    static get properties() {
        return {
            "download": {
                "type": "any",
                "mutable": false,
                "complexType": {
                    "original": "string | boolean",
                    "resolved": "boolean | string | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "If `true`, the user can save the linked URL instead of navigating to it."
                },
                "getter": false,
                "setter": false,
                "attribute": "download",
                "reflect": false,
                "defaultValue": "false"
            },
            "href": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The URL that the link points to."
                },
                "getter": false,
                "setter": false,
                "attribute": "href",
                "reflect": false
            },
            "hreflang": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The human language of the linked URL."
                },
                "getter": false,
                "setter": false,
                "attribute": "hreflang",
                "reflect": false
            },
            "referrerpolicy": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "ReferrerPolicy",
                    "resolved": "\"\" | \"no-referrer\" | \"no-referrer-when-downgrade\" | \"origin\" | \"origin-when-cross-origin\" | \"same-origin\" | \"strict-origin\" | \"strict-origin-when-cross-origin\" | \"unsafe-url\" | undefined",
                    "references": {
                        "ReferrerPolicy": {
                            "location": "global",
                            "id": "global::ReferrerPolicy"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "How much of the referrer to send when following the link."
                },
                "getter": false,
                "setter": false,
                "attribute": "referrerpolicy",
                "reflect": false
            },
            "rel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The relationship of the linked URL as space-separated link types."
                },
                "getter": false,
                "setter": false,
                "attribute": "rel",
                "reflect": false
            },
            "target": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string | undefined",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "The place to display the linked URL, as the name for a browsing context (a tab, window, or iframe)."
                },
                "getter": false,
                "setter": false,
                "attribute": "target",
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "deviceSize": {},
            "footerConfig": {},
            "foregroundColor": {}
        };
    }
    static get elementRef() { return "el"; }
    static get listeners() {
        return [{
                "name": "footerResized",
                "method": "footerResizeHandler",
                "target": "document",
                "capture": false,
                "passive": false
            }, {
                "name": "brandChange",
                "method": "footerBrandChangeHandler",
                "target": "document",
                "capture": false,
                "passive": false
            }];
    }
}
//# sourceMappingURL=ic-footer-link.js.map
