/*!
 * Built with Stencil
 * By PostNord.
 */
import { h, Host } from "@stencil/core";
import { open_in_new } from "pn-design-assets/pn-assets/icons.js";
import { URLS } from "./urls";
import { translations } from "./translations";
import { SE, NO, en, awaitTopbar } from "../../../globals/helpers";
/**
 * The default market and language is SE/en.
 *
 * Make sure you set the market **and** language prop.
 * Example: Setting the `language` prop `da` will not display anything, as `da` does not exist on the `SE` market.
 *
 * @deprecated This component has been replaced with the pn-footer-nav.
 * @see {@link https://portal.postnord.com/web-components/?path=/docs/external-components-pn-footer-nav--docs pn-footer-nav}
 */
export class PnFooter {
    hostElement;
    /** Set the market for the footer. */
    market = null;
    /** Set the language for the footer. */
    language = null;
    async componentWillLoad() {
        if (this.market && this.language)
            return;
        await awaitTopbar(this.hostElement);
    }
    getLink(name) {
        return URLS?.[this.market || SE]?.[name]?.[this.language || en];
    }
    getText(name) {
        if (name === 'domain')
            return this.getLink(name)?.replace('https://www.', '');
        return translations?.[name]?.[this.language];
    }
    renderLink(name) {
        const url = this.getLink(name);
        const text = this.getText(name);
        if (url && text) {
            return h("pn-text-link", { label: text, target: "_blank", rel: "noopener noreferrer", href: url, icon: open_in_new });
        }
    }
    render() {
        return (h(Host, { key: '5ba1e53dd0dc631bf8bbe878a622ec577224a9f3' }, h("div", { key: '530b0e803506fed3cae180d1289535538f64e1bb', class: "pn-footer-row" }, h("p", { key: '47e19b88eb7c6860f0921fdacc79686aff3d2b61' }, this.getText('questions')), this.renderLink('contact')), h("div", { key: '2986a92cb2183d53c871030db72ef34aa08e847b', class: "pn-footer-row" }, this.market !== NO && this.renderLink('terms'), this.renderLink('privacy'), this.renderLink('cookies')), h("div", { key: '550a23c5b872b6dc9c69b4e231ce7634d5f12994', class: "pn-footer-row" }, h("p", { key: '52871c90b92a2a64fc247ac83fdc62215e54a574' }, this.getText('info')), this.renderLink('domain'))));
    }
    static get is() { return "pn-footer"; }
    static get originalStyleUrls() {
        return {
            "$": ["pn-footer.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["pn-footer.css"]
        };
    }
    static get properties() {
        return {
            "market": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "PnMarkets",
                    "resolved": "\"\" | \"DK\" | \"FI\" | \"NO\" | \"SE\"",
                    "references": {
                        "PnMarkets": {
                            "location": "import",
                            "path": "@/globals/types",
                            "id": "src/globals/types.ts::PnMarkets",
                            "referenceLocation": "PnMarkets"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Set the market for the footer."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "market",
                "defaultValue": "null"
            },
            "language": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "PnLanguages",
                    "resolved": "\"\" | \"da\" | \"en\" | \"fi\" | \"no\" | \"sv\"",
                    "references": {
                        "PnLanguages": {
                            "location": "import",
                            "path": "@/globals/types",
                            "id": "src/globals/types.ts::PnLanguages",
                            "referenceLocation": "PnLanguages"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Set the language for the footer."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "language",
                "defaultValue": "null"
            }
        };
    }
    static get elementRef() { return "hostElement"; }
}
