import { Host, h } from "@stencil/core";
export class Link {
    constructor() {
        this.hasAnchor = false;
        /**
         * If true, displays the element as block rather than inline
         */
        this.stacked = false;
    }
    componentWillLoad() {
        this.hasAnchor = this.element.firstElementChild && this.element.firstElementChild.tagName === 'A';
    }
    onKeyUp(event) {
        if (this.hasAnchor || event.key !== 'Enter')
            return;
        this.element.click();
    }
    render() {
        return h(Host, { tabindex: this.hasAnchor ? undefined : 0 });
    }
    static get is() { return "anj-link"; }
    static get originalStyleUrls() { return {
        "$": ["link.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["link.css"]
    }; }
    static get properties() { return {
        "stacked": {
            "type": "boolean",
            "mutable": false,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": "If true, displays the element as block rather than inline"
            },
            "attribute": "stacked",
            "reflect": true,
            "defaultValue": "false"
        }
    }; }
    static get states() { return {
        "hasAnchor": {}
    }; }
    static get elementRef() { return "element"; }
    static get listeners() { return [{
            "name": "keyup",
            "method": "onKeyUp",
            "target": undefined,
            "capture": false,
            "passive": false
        }]; }
}
