import { h, Host } from "@stencil/core";
import { trackComponent } from "../../global/utils/tracking";
import { isNestedInIfxComponent } from "../../global/utils/dom-utils";
import { detectFramework } from "../../global/utils/framework-detection";
export class Card {
    constructor() {
        this.direction = 'vertical';
        this.href = "";
        this.internalHref = "";
        this.target = "_self";
    }
    setImgPosition(event) {
        this.alignment = event.detail;
    }
    handleComponentAdjustment() {
        const image = this.el.querySelector('ifx-card-image');
        const links = this.el.querySelector('ifx-card-links');
        this.noImg = !image;
        this.noBtns = !links;
        if (this.href.trim() === "") {
            this.internalHref = undefined;
        }
        else {
            this.internalHref = this.href;
        }
    }
    componentWillLoad() {
        this.handleComponentAdjustment();
    }
    async componentDidLoad() {
        if (!isNestedInIfxComponent(this.el)) {
            const framework = detectFramework();
            trackComponent('ifx-card', await framework);
        }
    }
    componentWillUpdate() {
        this.handleComponentAdjustment();
    }
    render() {
        return (h(Host, { key: 'd1342011d31f6978702f5a193191c97c40620d3a' }, h("div", { key: '0fad34f8282119b8a32647abaadb9c4d8c596b40', "aria-label": this.ariaLabel, class: `card 
            ${this.noBtns ? 'noBtns' : ""}
            ${this.direction} 
            ${this.alignment}`, role: "group" }, this.direction === 'horizontal' &&
            h("div", { key: '14bbc106ff828fc268bd5636d71ed66b85b3971e', class: "horizontal" }, h("a", { key: '7cd3f0f394d067ef375490fc96d71c15937b784a', class: `card-img ${this.noImg ? 'noImage' : ""} ${this.internalHref ? 'card-href' : ''}`, href: this.internalHref }, h("slot", { key: 'ce3be286399a863d0535b7886be602eda1da1e3a', name: "img" })), h("div", { key: '19d526f169cfdfc5921b3104e642b0390d40f57c', class: 'lower__body-wrapper' }, h("a", { key: 'e4af1b4915b38e8f31b6e539072142c8ab85e334', class: `upper-body ${this.internalHref ? 'card-href' : ''}`, href: this.internalHref, id: "upper-body-content" }, h("slot", { key: '28c6e43c2e4f4a47968c7b1054d8fe8eb2d148c6' })), h("div", { key: '708536495fed3c351f85823b7dfd52b56e7e7d97' }, h("slot", { key: '926da9864476efaa413ac167101a71ed265d8fa8', name: 'buttons' })))), this.direction === 'vertical' &&
            h("div", { key: '23350f711ef5cfbb298812f23d120927a67879c3', class: "vertical" }, h("a", { key: 'c740bb3957d400c7f0cc06a2052bbe80a1b184a7', class: `upper__body-wrapper ${this.internalHref ? 'card-href' : ''}`, href: this.internalHref, target: this.target }, h("div", { key: '9027ad5864dab44e18b2c9bd10c704d8329122f5', class: `card-img ${this.noImg ? 'noImage' : ""}` }, h("slot", { key: '509b69f84d36075351cbec657232b2c859c8cd9e', name: "img" })), h("div", { key: '3d7590db496cd6aaf0603ebf224a015324a86ce9', class: 'upper-body', id: "upper-body-content" }, h("slot", { key: '142c46ccd143f00c62e07c70b5ffcec5674666fd' }))), h("div", { key: '8245deceb8ff7e14408386eaeba2f5025ab75229', class: 'lower__body-wrapper', role: "group", "aria-labelledby": "upper-body-content" }, h("slot", { key: '0a0e0124cde655ccfddc59cbc91f2cd373e545b5', name: 'buttons' }))))));
    }
    static get is() { return "ifx-card"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["card.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["card.css"]
        };
    }
    static get properties() {
        return {
            "direction": {
                "type": "string",
                "attribute": "direction",
                "mutable": false,
                "complexType": {
                    "original": "'horizontal' | 'vertical'",
                    "resolved": "\"horizontal\" | \"vertical\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "'vertical'"
            },
            "href": {
                "type": "string",
                "attribute": "href",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "\"\""
            },
            "target": {
                "type": "string",
                "attribute": "target",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "\"_self\""
            },
            "ariaLabel": {
                "type": "string",
                "attribute": "aria-label",
                "mutable": false,
                "complexType": {
                    "original": "string | null",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "noBtns": {},
            "alignment": {},
            "noImg": {},
            "internalHref": {}
        };
    }
    static get elementRef() { return "el"; }
    static get listeners() {
        return [{
                "name": "imgPosition",
                "method": "setImgPosition",
                "target": undefined,
                "capture": false,
                "passive": false
            }];
    }
}
//# sourceMappingURL=card.js.map
