import { h, Host } from "@stencil/core";
import { translations } from "./translations";
import state from "./pn-sidenav-store";
export class PnSidenav {
    constructor() {
        this.language = 'sv';
        this.navLabel = '';
        this.i18n = { open: '', close: '', navLabel: '' };
    }
    hostElement;
    componentWillLoad() {
        this.init();
    }
    async init() {
        this.setLanguage();
        if (window.matchMedia('screen and (min-width:64em)').matches === false) {
            state.openMenu = false;
        }
    }
    setLanguage() {
        if (translations[this.language]) {
            state.i18n = translations[this.language];
            if (!this.navLabel) {
                this.navLabel = state.i18n.navLabel;
            }
        }
    }
    onOpenSubMenuLevelChange(event) {
        state.openLevel = event.detail;
    }
    render() {
        return (h(Host, { key: '030371f4286ce6ad8e5b75d579362c113e53fa36', open: (state.openMenu == true) + '' }, h("slot", { key: 'f701a5ce9c4cc237144ad9f8ae5a29d2ee50d547', name: "above" }), h("nav", { key: '79df4c5b53bd1184ab6737f5433e143efb035b74', class: "sidenav", "aria-label": this.navLabel }, h("slot", { key: '26afb12367f000520a8d5fecc197de1194cdd5a9' }))));
    }
    static get is() { return "pn-sidenav"; }
    static get originalStyleUrls() {
        return {
            "$": ["pn-sidenav.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["pn-sidenav.css"]
        };
    }
    static get properties() {
        return {
            "language": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Specifies which language we want to show navigation in (sv,da,fi,no,en)"
                },
                "attribute": "language",
                "reflect": false,
                "defaultValue": "'sv'"
            },
            "navLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Sets the label of the navigation (Required if multiple nav elements are on a page)"
                },
                "attribute": "nav-label",
                "reflect": false,
                "defaultValue": "''"
            }
        };
    }
    static get states() {
        return {
            "i18n": {}
        };
    }
    static get elementRef() { return "hostElement"; }
    static get listeners() {
        return [{
                "name": "language",
                "method": "setLanguage",
                "target": undefined,
                "capture": false,
                "passive": false
            }, {
                "name": "openSubMenuLevelChange",
                "method": "onOpenSubMenuLevelChange",
                "target": undefined,
                "capture": false,
                "passive": false
            }];
    }
}
//# sourceMappingURL=pn-sidenav.js.map
